Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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



WHAT WILL BE OUTPUT OF BELOW CODE . . AND PLEASE EXPLAIN HOW IT COME .. #include<stdio.h>..

Answer / robin

21212121

Is This Answer Correct ?    0 Yes 0 No

WHAT WILL BE OUTPUT OF BELOW CODE . . AND PLEASE EXPLAIN HOW IT COME .. #include<stdio.h>..

Answer / ramu

22 21 22 22

Is This Answer Correct ?    0 Yes 0 No

WHAT WILL BE OUTPUT OF BELOW CODE . . AND PLEASE EXPLAIN HOW IT COME .. #include<stdio.h>..

Answer / shashikanth

20 21 21 22

Is This Answer Correct ?    0 Yes 0 No

WHAT WILL BE OUTPUT OF BELOW CODE . . AND PLEASE EXPLAIN HOW IT COME .. #include<stdio.h>..

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

WHAT WILL BE OUTPUT OF BELOW CODE . . AND PLEASE EXPLAIN HOW IT COME .. #include<stdio.h>..

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

WHAT WILL BE OUTPUT OF BELOW CODE . . AND PLEASE EXPLAIN HOW IT COME .. #include<stdio.h>..

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

WHAT WILL BE OUTPUT OF BELOW CODE . . AND PLEASE EXPLAIN HOW IT COME .. #include<stdio.h>..

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

WHAT WILL BE OUTPUT OF BELOW CODE . . AND PLEASE EXPLAIN HOW IT COME .. #include<stdio.h>..

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

WHAT WILL BE OUTPUT OF BELOW CODE . . AND PLEASE EXPLAIN HOW IT COME .. #include<stdio.h>..

Answer / ramesh

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

WHAT WILL BE OUTPUT OF BELOW CODE . . AND PLEASE EXPLAIN HOW IT COME .. #include<stdio.h>..

Answer / balasankararao

my answer is
22 21 21 20

if it is wrong why?

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More C Interview Questions

This is a variation of the call_me function in the previous question:call_me (myvar)int *myvar;{ *myvar += 5; }The correct way to call this function from main() will be a) call_me(myvar) b) call_me(*myvar) c) call_me(&myvar) d) expanded memory

0 Answers  


how can i get output like this? 1 2 3 4 5 6

6 Answers   Excel,


What is the correct declaration of main?

0 Answers  


What is #include in c?

1 Answers  


C,c++, Java is all are structural oriented or procedure oriented language..?

6 Answers  


write a c program to find the sum of five entered numbers using an array named number

0 Answers   TATA,


What should malloc(0) do?

0 Answers  


pierrot's divisor program using c or c++ code

0 Answers  


1. What will be the output of the following programs. a) #include <stdio.h> Main() { Int x=4; While(x==1) { X=x-1; Printf(ā€œ%dā€,x); --x; } }

7 Answers   CSC,


Can we access the array using a pointer in c language?

0 Answers  


Explain how to reverse singly link list.

0 Answers  


If 4 digits number is input through the keyboard, Write a program to calculate sum of its 1st & 4th digit.

12 Answers   Google,


Categories