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

a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f

0 Answers   TCS,


What is the difference between procedural and declarative language?

0 Answers  


Why the below program throughs error during compilation? #include<stdio.h> #include<conio.h> enum { ZERO, ONE, TWO, }; main() { printf("%d",&TWO); getch(); }

2 Answers  


Can you write the algorithm for Queue?

0 Answers   College School Exams Tests, TCS,


Can anyone tell what is stack overflow? what precaution we should take?

1 Answers  


# define prod(a,b)=a*b main() { int x=2; int y=3; printf("%d",prod(x+2,y-10)); } the output of the program is a.8 b.6 c.7 d.none

7 Answers   Microsoft, TCS,


List the difference between a While & Do While loops?

0 Answers   Accenture,


What is the difference between fread buffer() and fwrite buffer()?

0 Answers  


What is true about the following C Functions (a) Need not return any value (b) Should always return an integer (c) Should always return a float (d) Should always return more than one value

2 Answers   DynPro, TCS,


how to find out the union of two character arrays?

2 Answers  


write a program for fibonaci series by using while loop in c?

2 Answers  


Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon

0 Answers  


Categories