C Programming

Status
Not open for further replies.

Mohan Giri

In Runtime
Messages
144
Hai Everybody,
Happy New Year to all. When we use user defined functions in our program, if we declare two different types of data ( calling function data type and called function data type are different) what will be the output? Will we get any error message?????????
 
Calling function is a function which is declared within main function. Called function is a function which sends result after processing the code to the calling function in main function.

For ex...

main()
{
int a,b,c;
a=5;
b=8;
c=add(a,b)
printf(c);
}
int add(int y, int x)
{
int z=y+x;
return z;
}


here c=add(a,b) is a calling funtion and add(y,x) is a called function.
 
So why don't you just code it and try run it, then you will know what will happen.
 
At present I do not have C Compiler in my PC. I had some problem in my pc. So I formatted everything. I am waiting for a good C Compiler now.
 
so you mean:
main()
{
int a,b,c;
a=5;
b=8;
c=add(a,b)
printf(c);
}
int add(int y, int x)
{
int z=y+x;
return z;
}

here if c has been defined as int ,but the called function add(int,int) has defined as returning float,then you call there are two different types of data ?
 
main()
{
int a,b,c;
a=5;
b=8;
c=add(a,b)
printf(c);
}
int add(int y, int x)
{
int z=y+x;
return z;
}


here you have to declare add(int,int) first becoz you are defining it after the call has been made. otherwise simply put the definition before main likr:......

int add(int y, int x)
{
int z=y+x;
return z;
}
main()
{
int a,b,c;
a=5;
b=8;
c=add(a,b);
//printf("%d",c);
}
 
Status
Not open for further replies.
Back
Top Bottom