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);
}

Answers were Sorted based on User's Feedback



What will be printed as the result of the operation below: #include<..> int x; int modi..

Answer / civa


The Output will be:

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

Is This Answer Correct ?    24 Yes 3 No

What will be printed as the result of the operation below: #include<..> int x; int modi..

Answer / 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

More C Interview Questions

what are threads ? why they are called light weight processes ? what is the relation between process and threads ?

1 Answers  


what is the hardware model of CFG( context free grammar)

0 Answers   Microsoft,


write a program that uses point of sale system. which are mainly used by retail markets, where the is a database inventory list, a slip should be printed for the customer. manage should be able to access what has been sold and what is left from stock?

1 Answers  


How would you write qsort?

1 Answers  


Explain can the sizeof operator be used to tell the size of an array passed to a function?

0 Answers  






What does %p mean c?

0 Answers  


How does selection sort work in c?

0 Answers  


What is the time and space complexities of merge sort and when is it preferred over quick sort?

0 Answers   Amazon,


what is the code for getting the output as * ** ***

5 Answers   Caritor,


int main(){ float f=8.0; if(f==8.0) printf("good"); else printf("bad"); } what is the answere and explain it?

3 Answers  


What is wild pointer in c with example?

0 Answers  


what is difference between ANSI structure and C99 Structure?

1 Answers   Wipro,


Categories