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

Should I learn c before c++?

0 Answers  


sir, i cannot find the way how to write aprogram by using array on queue

1 Answers   IISIT,


Explain how do you determine the length of a string value that was stored in a variable?

0 Answers  


How can you increase the size of a dynamically allocated array?

0 Answers   TISL,


Explain the Difference between the New and Malloc keyword.

0 Answers   InterGraph,






Input is "Jack and jill went up a hill" To print output is 1-letter word(s)-1 2-letter words-1 3-letter words-1 4-letter words-4

1 Answers   Mind Tree, TCS,


What are the 32 keywords in c?

0 Answers  


What is malloc and calloc?

0 Answers  


all c language question

0 Answers   Wipro,


we called a function and passed something do it we have always passed the "values" of variables to the called function. such functions calles are called a) calls by reference b) calls by value c) calls by zero d) none of the above

0 Answers  


What is the most efficient way to count the number of bits which are set in a value?

4 Answers  


what are bps & baud rates? differentiate these two?

2 Answers   TCS,


Categories