Originally Posted by

**powerfox0**
Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int sum1;
sum1 = 7+3*5-2;
printf("the first equation is 7+3*5-2 \n");
printf("the answer of the first equation is %d\n", sum1);
int sum2;
sum2 = 4+7/3;
printf("the second equation is 4+7/3 \n");
printf("the answer of the second equation is %d\n", sum2);
int sum3;
sum3 = 8%3*6;
printf("the third equation is 8/3*6 \n");
printf("the answer of the third equation is %d\n", sum3);
int sum4;
sum4 = (7+3)*5-2;
printf("the fourth equation is (7+3)*5-2 \n");
printf("the answer of the fourth equation is %d\n", sum4);
return EXIT_SUCCESS;
}

thank you to everyone for their help.

this is my final code for part 1, it seems to be working. can someone please verify that this is correct?

Does it run for you? It does not run for me unless I declare the variables at the top (see code). I think its something to do with the different C standards. With C89, you have to declare variables at the top of the scope.

Also, look at sum3. There is a mistake there. Can you find it? HINT: sum3 is the correct value but the sentence is incorrect

Everything else seems to be good. Perhaps add paragraphs and comments to finish it off?

Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int sum1, sum2, sum3, sum4;
sum1 = 7+3*5-2;
printf("the first equation is 7+3*5-2 \n");
printf("the answer of the first equation is %d\n", sum1);
//int sum2;
sum2 = 4 + 7/3;
printf("the second equation is 4+7/3 \n");
printf("the answer of the second equation is %d\n", sum2);
//int sum3;
sum3 = 8%3*6;
printf("the third equation is 8/3*6 \n");
printf("the answer of the third equation is %d\n", sum3);
//int sum4;
sum4 = (7+3)*5-2;
printf("the fourth equation is (7+3)*5-2 \n");
printf("the answer of the fourth equation is %d\n", sum4);
getchar();getchar();
return 0;
}