Hi folks,
I'm trying following code..
#include<stdio.h>
int calsum(int a,int b,int c);
int main(){
int x,y,z,sum=0;
printf("Enter the 3 numbers:\n");
scanf("%d%d%d",&x,&y,&z);
sum=calsum(x,y,z);
printf("The vlaue of sum is :%d\n",sum);
return 0;
}
int calsum(int a,int b,int c){
int d=0;
printf("The value of d is:%d",d);
d=a+b+c;
}
** (1) **
When I compile with
gcc -o test_cal test_cal.c
It not giving any warning and when I execute it, it is returning actual summation to the main.
Program works perfectly.
** (2) **
But when I compile with
gcc -Wall -Werror -o test_cal test_cal.c
It is giving me a warning..
cc1: warnings being treated as errors
test_cal.c: In function ‘calsum’:
test_cal.c:20: error: control reaches end of non-void function
I'm using gcc version 4.4.4 and Fedora 13. Can anybody explain me, how the code works in 1st case?