what is the output of following program ?
void main()
{
int i=5;
printf("%d %d %d %d %d ",i++,i--,++i,--i,i);
}

Answers were Sorted based on User's Feedback



what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / sameeksha agrawal

ya i can tell u abt d ans ..the reasn behind it x++ is
example of post increament in which frstly value of any
variable is prnt thn oprtr r prfrmed and the oprtions r
perfrmd frm right side...

Is This Answer Correct ?    7 Yes 2 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / sandeep gupta

Friends, actually the output is compiler dependent. Never
give any specific answer in this type of questions because C
does not provide any format in evaluation order of postfix
and prefix expressions when passed to any functions like
printf() eg. fun1(i++,i) may pass fun1(5,6) in some
compilers and fun1(5,5) in another. So it totally depends on
what compiler we're using.

Is This Answer Correct ?    4 Yes 0 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / sameeksha agrawal

45545

Is This Answer Correct ?    9 Yes 6 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / jalp

Here if i do it manually then i got 44545 but compiler shows
me : 45545

Can any body show the stack process that how it execute
internally,

And also reply through mail.
Thanks.

Is This Answer Correct ?    6 Yes 5 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / jalp

That i know .. I want to know the stack process , how it
internally works .. if you elaborate through step then
please explain it ..

Thanks.

Is This Answer Correct ?    2 Yes 1 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / kavsac

Guys,
There is something, I wanna add on. The above result occurs only in windows, in Unix its 56656

Is This Answer Correct ?    2 Yes 1 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / shenbagam

in c its left to right operation will be perfomed by
compiler..... so take this

int i=5;
printf("%d %d %d %d %d ",i++,i--,++i,--i,i);


i=5;

--i=4; after tis the value of i=4 only;

because --i will decrement the value of i, and then return the decremented value.

++i=5; after this the value of i=5;

because ++i will increment the value of i, and then return the incremented value.

i--=5; after this the value of i=4;

because will decrement the value of i, but return the pre-defind value of i. so i=5 before the step na?.....

i++=4; after this the value of i=5;

because will increment the value of i, but return the pre-defined value of i.so i=4 before the step na?...


so only the result will be like 45545 this.......


int i=5;
printf("%d %d %d %d %d ",i++,i--,++i,--i,i);

after the step if u print i; the value must be 5


only......... so the doubt will be cleared aha?............

all the best:):):):).

Is This Answer Correct ?    4 Yes 3 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / sameeksha agrawal

no Kavsac u r wrng try again its answer...

Is This Answer Correct ?    0 Yes 0 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / sameeksha agrawal

sry u r totally wrng cz c is structrd progrmmmng languaga

Is This Answer Correct ?    0 Yes 0 No

what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d &qu..

Answer / sindhu

Answer:after compilation i got 45545.... but if i consider it from left to right in manual my answer is 55454...

i want clear xplanation for tis program...

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Code Interview Questions

union u { union u { int i; int j; }a[10]; int b[10]; }u; main() { printf("\n%d", sizeof(u)); printf(" %d", sizeof(u.a)); // printf("%d", sizeof(u.a[4].i)); } a. 4, 4, 4 b. 40, 4, 4 c. 1, 100, 1 d. 40 400 4

3 Answers   HCL,


void main() { int i; char a[]="\0"; if(printf("%s\n",a)) printf("Ok here \n"); else printf("Forget it\n"); }

3 Answers   Accenture,


main( ) { static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *++ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); ++*ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); }

2 Answers   Persistent,


main() { int x=5; for(;x!=0;x--) { printf("x=%d\n", x--); } } a. 5, 4, 3, 2,1 b. 4, 3, 2, 1, 0 c. 5, 3, 1 d. none of the above

2 Answers   HCL,


void main() { int *mptr, *cptr; mptr = (int*)malloc(sizeof(int)); printf(“%d”,*mptr); int *cptr = (int*)calloc(sizeof(int),1); printf(“%d”,*cptr); }

1 Answers  






A program that will create a movie seat reservation. The program will display the summary seats and its status. The user will be ask what seat no. to be reserved, then it will go back again to the summary to display the updated seat status. If the seat no. is already reserved then it will prompt an error message. And also if the input seat no is out of range then it will also prompt an error message. The program is continuously running. Termination of the program will depends on how the programmer will apply. Sample output: Movie Seats Reservation Summary of Seats: Seat 1: Available Seat 2: Available Seat 3: Available Seat 4: Available Seat 5: Available Enter seat no. (Press 0 to terminate Or the assigned seat capacity) : 1 Movie Seats Reservation Summary of Seats: Seat 1: Reserve Seat 2: Available Seat 3: Available Seat 4: Available Seat 5: Available Enter seat no. (Press 0 to terminate Or the assigned seat capacity) : 6 The Seat no. is out of range! Movie Seats Reservation Summary of Seats: Seat 1: Reserve Seat 2: Available Seat 3: Available Seat 4: Available Seat 5: Available Enter seat no. (Press 0 to terminate Or the assigned seat capacity) : 1 The Seat no. is already reserved! Movie Seats Reservation Summary of Seats: Seat 1: Reserve Seat 2: Available Seat 3: Available Seat 4: Available Seat 5: Available Enter seat no. (Press 0 to terminate Or the assigned seat capacity) : 0 GoodBye... Thank You!!!

0 Answers  


How will you print % character? a. printf(“\%”) b. printf(“\\%”) c. printf(“%%”) d. printf(“\%%”)

4 Answers   HCL,


Write a program to receive an integer and find it's octal equivalent. How can i do with using while loop.

2 Answers  


Write a program to check whether the number is prime and also check if it there i n fibonacci series, then return true otherwise return false

1 Answers   Cognizant, lenovo,


main() { int i =0;j=0; if(i && j++) printf("%d..%d",i++,j); printf("%d..%d,i,j); }

1 Answers  


main(int argc, char **argv) { printf("enter the character"); getchar(); sum(argv[1],argv[2]); } sum(num1,num2) int num1,num2; { return num1+num2; }

1 Answers  


Derive expression for converting RGB color parameters to HSV values

1 Answers  


Categories