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();
}
Answer Posted / mohamed ali
THE ANSWER IS
20 20 22 22
YOU HAVE THE 1ST 20 AS IT'S THE INITIAL VALUE
THEN YOU HAVE K++ .... HERE WE HAVE THE SAME VALUE OF K THEN
IT WILL BE INCREMENTED BY ONE .... SO YOU HAVE THE 2ND 20
AND THEN K WILL BE 21
THE THIRD YOU HAVE ++K .... WHICH MEANS THAT YOU WILL
INCREMENT THEN TYPE THE VALUE AND SINCE YOU HAVE NOW K=21
FROM PREVIOUS STEP (K++) SO THIS VALUE WILL BE INCREMENTED
BY ONE (K = 22 ) SO YOU HAVE THE THIRD VALUE 22
THEN YOU HAVE A SINGLE K WITH NO OPERATIONS SO ANOTHER 22
IF SOMEONE SEES THAT I'M WRONG PLZ CORRECT MY VIEW
THANKS
| Is This Answer Correct ? | 8 Yes | 5 No |
Post New Answer View All Answers
Explain how do you convert strings to numbers in c?
hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...
Explain null pointer.
Differentiate between null and void pointers.
If null and 0 are equivalent as null pointer constants, which should I use?
What is a function in c?
In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none
What is the use of clrscr?
What is advantage of pointer in c?
Why is c called c?
Is that possible to store 32768 in an int data type variable?
What is #line used for?
What is difference between class and structure?
What is the return type of sizeof?
What are structure types in C?