I've written this code and for the life of me can't figure out why the compiler won't read it.
It tells me
Code:
Question4.c:7:1: error: expected identifier or '(' before '{' token
Question4.c:31:1: warning: missing terminating " character
Question4.c:31:1: warning: missing terminating " character
(Question4.c is the name of the file).
To be honest I have looked all over the program, even at the lines I think the compiler is suggesting and can find no issue.
Can anyone help?
Code:
#include<stdio.h>
{
int main()
int num1, num2, sum;
char operation[1];
printf("Enter first number:");
scanf("%d", &num1 );
printf("Enter operation + or - or * or /: ");
scanf("%c", &operation);
printf("Enter second number:");
scanf("%d", &num2 );
"if ( operation == '+' )"
{
sum = num1 + num2;
printf("The sum of %d and %d is %d ", num1, num2, sum);
}
"if ( operation == '-' )"
{
sum = num1 - num2 ;
printf("Subtracting %d from %d is %d ", num2, num1, sum);
}
"if ( operation == '*' )"
{
sum = num1 * num2;
printf("Multiplying %d by %d is %d ", num1, num2, sum);
"}
"if ( operation == '/' )"
{
sum = num1 / num2 ;
printf("Dividing %d by %d is %d ", num2, num1, sum);
}
return 0;
}