Correct form to declare and use function in C.
/*
correct form to declare and use function in c
first declare before main() to avoid any error
then we can use it
orr you declare funtions write code in them above main()
it'll be easy and will be short
orr just delete the code part from calsum above main()
and remove comment from calsum below main()
you'll get another form of code
*/
#include <stdio.h>
int calsum(int x, int y, int z)
{
int d ;
d = x + y + z ;
return ( d ) ;
}
void main()
{
int a, b, c, sum ;
printf ( "\nEnter any three numbers " ) ;
scanf ( "%d %d %d", &a, &b, &c ) ;
sum = calsum ( a, b, c ) ;
printf ( "\nSum = %d", sum ) ;
}
/*int calsum ( int x, int y, int z )
{
int d ;
d = x + y + z ;
return ( d ) ;
}*/
Comments
Post a Comment