What will be printed as the result of the operation below:

#include<..>

int x;
int modifyvalue()
{
return(x+=10);
}
int changevalue(int x)
{
return(x+=1);
}
void main()
{
int x=10;
x++;
changevalue(x);
x++;
modifyvalue();
printf("First output:%d\n",x);
x++;
changevalue(x);
printf("Second output:%d\n",x);
modifyvalue();
printf("Third output:%d\n",x);
}

Answer Posted / selloorhari

The Output will be:

First output : 12
Second output : 13
Third output : 14

for changevalue() function:
Even though the value of x(11) is sent to
changevalue() and it returns x(12), no variable is assigned
to capture that 12. So, in main() function, x remains as 11(
not as 12 ) . then it gets incremented and prints the value
12...

And, the Same story for other functions also.....

Is This Answer Correct ?    2 Yes 16 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a function argument have default value?

661


What are the types of data structures in c?

594


Why c is a procedural language?

576


how to create duplicate link list using C???

2061


Explain how can a program be made to print the line number where an error occurs?

684






How can you determine the size of an allocated portion of memory?

734


a number whose only prime factors are 2,3,5, and 7 is call humble number,,write a program to find and display the nth element in this sequence.. sample input : 2,3,4,11,12,13, and 100.. sample output : the 2nd humble number is 2,the 3rd humble number is 3,the 4th humble number is ,the 11th humble number is 12, the 12th humble number is 14, the 13th humble number is 15, the 100th humble number is 450.

4536


What is the size of enum in c?

612


What are the disadvantages of external storage class?

582


Why enum is used in c?

515


What is the difference between Printf(..) and sprint(...) ?

778


In c language can we compile a program without main() function?

567


Who is the founder of c language?

671


What are header files? What are their uses?

630


How can this be legal c?

645