WHAT WILL BE OUTPUT OF BELOW CODE . . AND PLEASE EXPLAIN HOW
IT COME ..
#include<stdio.h>
#include<conio.h>
void main()
{
int k=20;
printf("%d%d%d%d",k,k++,++k,k);
getch();
}
Answers were Sorted based on User's Feedback
Answer / karthikeyan
20 20 22 22
solution
1) k corresponds to 20 20
2) k++ corresponds to k = k then k+1 20
after assignment k becomes 21
3) ++k corresponds to k + 1 then k = k 22
4) k corresponds to k 22
| Is This Answer Correct ? | 3 Yes | 4 No |
Answer / prats
its stack operation . .
top will get printed first . .
answer will b 22 21 21 20
| Is This Answer Correct ? | 1 Yes | 2 No |
Answer / robin
different compiler gives different ans..
this is for tc
but its true it work as stack
last in first out
value of k is store in stack
1. k = 20
2. ++k = 21 (Pre Increment )
3. k++ = 21 (Post Increment(k value now is 22))
4. k = 22
As 22 is last it is printed 1st.........
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / dasari prasad
Output is 22 21 21 22
Because n printf evaluation starts from last parameter
because of STACK.. so calculate k value from last i.e k=20
and ++k=21 ,k++=21(post incre),k=22.
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / puja
THE ANSWER WILL BE
20 20 22 22
BECAUSE THE FIRST VALUE IS K=20 THEN IT WILL BE THE SAME
20 DUE TO K++, NOW THE VALUE WILL BE INCREMENTED & WILL BE
21, THEN ++K, MEANS THE VALUE WILL BE +1 THEN IT WILL BE 22
& LAST K WILL BE SAME 22.
| Is This Answer Correct ? | 3 Yes | 5 No |
Here i like to say one think,dont allow different answer,if
its correct you may do this.so many of them taking to
verify or knowing the answer.so allow only the answer which
are correct.dont allow any wrong any answers for all the
questions.because it is very using in right time should not
make confuse others.
| Is This Answer Correct ? | 1 Yes | 3 No |
Answer / balasankararao
my answer is
22 21 21 20
if it is wrong why?
| Is This Answer Correct ? | 1 Yes | 3 No |
int main() { int days; printf("enter days you are late"); scanf("%d",days); if (days<=5) printf("5o paisa fine"); if (days<=10&&days>=6) printf("1rs fine"); if(days>10) printf("10 rs fine"); if(days=30) printf("membership cancelled"); return 0; } tell me whats wrong in this program? is it right?
main() { int a[10]; printf("%d",*a+1-*a+3); }
can anyone please tell me wat is backlogs... i was looking for the job openings where i read this.. eligibility criteria minimum 70% in degree without backlogs. is that arrear.. if so is it standing arrear or history of arrears... please help me...
11 Answers CTS, Indian Navy, L&T, Microsoft, SSB, TCE, TCS,
What is difference between %d and %i in c?
How many main () function we can have in a project?
What is malloc calloc and realloc in c?
WHAT IS MEANT BY LIFE?
What is a function in c?
What is sizeof array?
what is the output of printf("%d",(scanf("%d",10));
WRITE A PROGRAM TO PRINT THE FOLLOWING OUTPUTS USING FOR LOOPS. A) * B) ***** *** * * ***** * * *****
Write the program for displaying the ten most frequent words in a file such that your program should be efficient in all complexity measures.