What is being returned?

#include "stdio.h"
int main()
{
int i=10,j=20,k;
k=addsub(i,j);
printf("k=%d",k);
return 0;
}
addsub(int c, int d)
{
int x,y;
x=c-d;y=c+d;
return (x,y);
}

it’s the value of y which is returned here, because return statement never gives error if you write more than one arguments to it separated by a comma..it’s the last argument which is returned always.
so, the output is

k=30

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s