Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Objective-C
#include< stdio.h>
#include< conio.h>
void main();
{
   int a,b,c,d;
   clrscr();
   a=20,b=21,c=23;
   d=a+b+c;
   printf("sum of values",d);
getch();
}
Posted
Updated 29-May-15 18:34pm
v2

I think that the problem is here:
C++
void main();

The semicolon in C tells to the compiler that a statement[^] is complete.
In this case we are defining the function 'main' which is a declaration Compound statement[^].
Closing such a declaration before the body is an error. The correct code is:
C++
void main()
{
   ...    //Function body code
}

For sake of completeness I would add that closing before body some other compound statement, where the body is not mandatory, is not an error.
I.e. a while, a for, etc.
C++
for (i=0; i<10; i++)
  ;    //Do nothing

This coulld be write also as:
C++
for (i=0; i&lt;10; i++);    //Equivalent to former
 
Share this answer
 
v2
Comments
CHill60 1-Jun-15 6:13am    
Good spot! +5
Frankie-C 1-Jun-15 6:15am    
:-)
It could be
C++
printf("Sum of values: %d", d);
Please see:
http://www.cplusplus.com/reference/cstdio/printf[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900