Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 01-06-2005, 05:49 AM   #1 (permalink)
 
True Techie

Join Date: Dec 2004

Posts: 145

Mohan Giri

Default C Programming

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?????????
Mohan Giri is offline  
Old 01-06-2005, 02:32 PM   #2 (permalink)
 
Junior Techie

Join Date: Dec 2004

Posts: 88

developer

Default Re: C Programming

Quote:
calling function data type and called function data type are different)
What do you mean by callin datatype and called data type?
__________________
Somewhere I Belong...
developer is offline  
Old 01-06-2005, 10:51 PM   #3 (permalink)
 
True Techie

Join Date: Dec 2004

Posts: 145

Mohan Giri

Default

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.
Mohan Giri is offline  
Old 01-09-2005, 08:14 PM   #4 (permalink)
 
Super Techie

Join Date: Jan 2005

Posts: 295

gab00n

Default

So why don't you just code it and try run it, then you will know what will happen.
__________________
\"Today\'s scientists have substituted mathematics for experiments, and they wander off through equation after equation, and eventually build a structure which has no relation to reality.\" Nikola Tesla
gab00n is offline  
Old 01-10-2005, 11:02 PM   #5 (permalink)
 
True Techie

Join Date: Dec 2004

Posts: 145

Mohan Giri

Default

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.
Mohan Giri is offline  
Old 01-12-2005, 03:54 AM   #6 (permalink)
 
Newb Techie

Join Date: Jan 2005

Posts: 16

mohoo

Default

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 ?
mohoo is offline  
Old 01-12-2005, 10:39 AM   #7 (permalink)
 
Newb Techie

Join Date: Jan 2005

Posts: 9

holy_devil_

Default

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);
}
holy_devil_ is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On