•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 429,791 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,831 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 245 | Replies: 3
![]() |
•
•
Join Date: Aug 2008
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
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.
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.
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.
•
•
•
•
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;
•
•
•
•
>Warning W8070 keelan.c 30: Function should return a value in function
main
int main( void ) { return 0; }
"No man's life, liberty, or property is safe while the legislature is in session." ~ Mark Twain
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:
Therefore the proper writing of it it would be:
c Syntax (Toggle Plain Text)
int main ( void ) { /* your code here */ return 0; /* when you are finish exit with success status */ }
Last edited by Aia : Aug 7th, 2008 at 7:26 am.
"No man's life, liberty, or property is safe while the legislature is in session." ~ Mark Twain
![]() |
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: need a help with fopen
- Next Thread: need help replacing characters



Linear Mode