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
When was c language developed?
Write a program for finding factorial of a number.
A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream
Define recursion in c.
Is python a c language?
What are the disadvantages of a shell structure?
Why malloc is faster than calloc?
Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;
What is a const pointer in c?
What is ## preprocessor operator in c?
Explain what is the stack?
What is the code in while loop that returns the output of given code?
application areas a 'c' a) operating system b) graphics, interpreter, assembler c) program evalution, communication softwares d) all the above
c program to compute AREA under integral
What are valid operations on pointers?