main()
{
int i=5;
printf("%d%d%d%d",i++,i--,i);
}
Answers were Sorted based on User's Feedback
Answer / sravan kumer
Answer is 455848 in 'Turbo C++'
because here gave 4 %d's but given variables to print are 3.
So here Turbo C++ will evaluate first 3 parameters given as
---> first i will be evaluated so i=5 because printf() evaluates from right to left.
---> then i-- is 5 because it is post decrement so 1st prints value and then increments i=4
---> then i++ is post increments so 1st prints i value i.e 4
and then it will be incremented to 5.
---> so it printf will print 455 but there is another %d ,printf will handle those with a garbage values i.e 848 here.
so answer is 455848.i.e 455 is common after that some garbage value will be printed.
| Is This Answer Correct ? | 1 Yes | 0 No |
some garbage value , 4,5,5...
why in this o/p garbage value is because only 3 parameters
are passed but we have assigned 4 control strings , where
one control string is useless, so for that compiler will
print garbage value....
| Is This Answer Correct ? | 2 Yes | 4 No |
Answer / sravankumar
printf() function evaluates from right to left
printf("\n %d %d %d",i++,i--,i);
4 5 5
<- <- <- <- <-evaluation of expression
but prints as the way we mentioned in printf() function
i.e first i = 5
then i--= 5 because it is post decrement
then i++= 4 this because i is decremented in above, and
not incremented immediately because is post
increment
So output is : 4 5 5
| Is This Answer Correct ? | 0 Yes | 3 No |
Answer / sunil5a2
4 5 5
printf excutes form lefthand side onwords..
| Is This Answer Correct ? | 0 Yes | 5 No |
Write a program in c to print 1 121 12321 1234321 123454321
11 Answers ANR, College School Exams Tests, Mu Sigma, Wipro,
write the output of following code .. main() { static int a[]={10,20,30,40,50}; int *ptr=a; static int arr[2][2]={1,2,3,4}; char str[]="ABCD * 4#"; char *s=str+2; int i,j; for(i=0;i<5,i++) printf("%d",*ptr++); for(i=0;i<2;i++) for(j=0;j<2;j++) printf("%d\n",*(*(n+i)+j)); printf("%c\n%c\n%c\n",*(str+2),*s++,*--s); }
What are external variables in c?
What does sizeof function do?
Write a C program to find the smallest of three integers, without using any of the comparision operators.
What does s c mean on snapchat?
What is key word in c language?
What is the value of c?
change to postfix a/(b+c*d-e)
how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.
write a c program to change only the 3rd bit of the particular number such that other bits are not affected.. if bitnum=10(say.. it can be any no..
how does a general function , that accepts an array as a parameter, "knows" the size of the array ? How should it define it parameters list ?