O.k i searched the site but didn't find anything related to my problem.
all ive done is made a simple calculator using the "else if" command.
I'll post my coding and compiler errors below.

#include <stdio.h>
main()
{

	int valid =0;
	char operator;
	float number1,number2,sum;

		printf("calculator\n");
		printf("number\t operator\t number");
		scanf("%f\t %c\t %f\t", &number1, &operator, &number2);

		
		if(operator == '+')
			sum = number1 '+' number2;
		else if(operator =='-')
			sum = number1 '-' number2;
		else if(operator =='/')
			sum = number1 '/' number2;
		else if(operator == '*')
			sum = number1 '*' number2;
		else
			valid = 1;

		if(valid != 1)
			printf("%f %c %f = %f", number1, operator, number2, sum);
		else
			printf("invalid command unlucky");
}

compile errors are as follows :
Error E2379 keelan.c 15: Statement missing ; in function main
Error E2379 keelan.c 17: Statement missing ; in function main
Error E2379 keelan.c 19: Statement missing ; in function main
Error E2379 keelan.c 21: Statement missing ; in function main
Warning W8070 keelan.c 30: Function should return a value in function main
*** 4 errors in Compile ***

now to my knowledge the: else for, for or while command don't use ; as a close.
as you can see I'm new to programming so don't be to harsh please.
thanks.

Aia commented: Good job posting code, errors warning and concern. +9

Error E2379 keelan.c 15: Statement missing ; in function main
Error E2379 keelan.c 17: Statement missing ; in function main
Error E2379 keelan.c 19: Statement missing ; in function main
Error E2379 keelan.c 21: Statement missing ; in function main

if(operator == '+')
			sum = number1 '+' number2;
		else if(operator =='-')
			sum = number1 '-' number2;
		else if(operator =='/')
			sum = number1 '/' number2;
		else if(operator == '*')
			sum = number1 '*' number2;

Remove the ' ' enclosing the arithmetic operators.

>Warning W8070 keelan.c 30: Function should return a value in function
main

That one it telling you that main should return an int.

int main( void )
{
    return 0;
}

ok thanks for the help. i fixed the ; issue, i dont understand what you mean with the return 0; though.

The main function returns an integer no matter what when it runs within a host environment.
Therefore the proper writing of it it would be:

int main ( void )
{
     /* your code here */
     return 0;  /* when you are finish exit with success status */
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.