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


Please Help Members By Posting Answers For Below Questions

write an algorithm to display a square matrix.

2218


What type is sizeof?

580


What is external variable in c?

607


Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1

3651


What is queue in c?

574






Which of these functions is safer to use : fgets(), gets()? Why?

631


An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

665


Is there any data type in c with variable size?

628


Explain the term printf() and scanf() used in c language?

589


Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?

2051


What is string in c language?

618


Explain how many levels deep can include files be nested?

622


can any one tel me wt is the question pattern for NIC exam

1553


What are the 4 types of organizational structures?

621


How do you sort filenames in a directory?

708