#include%26lt;stdio.h%26gt;
int calsum(int x,int y, int z);
main()
{
int a,b,c, sum;
printf("\n Enter any three numbers");
scanf("%d %d %d",%26amp;a, %26amp;b, %26amp;c);
sum = calsum(a,b,c);
printf("\nSum=%d",sum);
}
int calsum(int x,int y,int z)
int x,y,z,;
{
int d;
d=x+y+z;
return (d);
}
error messages is
function should return a value in function main()
declaration syntax error
deceleration terminated incorrectly
Plz tell me where I am wrong
C code problem?
#include%26lt;stdio.h%26gt;
int calsum(int x,int y, int z); **** write int calsum(int, int, int);
main()
{
int a,b,c, sum;
printf("\n Enter any three numbers");
scanf("%d %d %d",%26amp;a, %26amp;b, %26amp;c);
sum = calsum(a,b,c);
printf("\nSum=%d",sum);
}
int calsum(int x,int y,int z)
int x,y,z,; ****remove this
{
int d;
d=x+y+z;
return (d); ***use return d;
}
Please try then tell me if u still encounter error
Reply:main() should be void main()
replace the main() by void main()
Reply:return 0;
in main
Reply:The main method returns an integer value by default. Since in your code, no value is returned by the main(), the error occurs.
You may either choose to define main as
void main()
{
// your code goes here
}
or,
main()
{
// your code
return 0;
}
Reply:type return 0; in the last line in the main program. surely this will solve this problem
medium
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment