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

What is a MAC Address?

628


What is the description for syntax errors?

615


What library is sizeof in c?

574


What are the differences between new and malloc in C?

610


What is the basic structure of c?

557






How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?

582


What is the stack in c?

720


Write a C program linear.c that creates a sequence of processes with a given length. By sequence it is meant that each created process has exactly one child. Let's look at some example outputs for the program. Here the entire process sequence consists of process 18181: Sara@dell:~/OSSS$ ./linear 1 Creating process sequence of length 1. 18181 begins the sequence. An example for a sequence of length three: Sara@dell:~/OSSS$ ./linear 3 Creating process sequence of length 3. 18233 begins the sequence. 18234 is child of 18233 18235 is child of 18234 ........ this is coad .... BUt i could not compleate it .....:( #include #include #include #include int main(int argc, char *argv[]) { int N; pid_t pid; int cont; if (argc != 2) { printf("Wrong number of command-line parameters!\n"); return 1; } N = atoi(argv[1]); printf("Creating process sequence of length %d.\n",N); printf("%d begins the sequence.\n",getpid()); /* What I have to do next ?????? */ }

1620


Explain what is wrong with this program statement?

621


What is page thrashing?

653


What will be the outcome of the following conditional statement if the value of variable s is 10?

767


Why do we use static in c?

634


Can the size of an array be declared at runtime?

610


What are the advantages of using linked list for tree construction?

645


The statement, int(*x[]) () what does in indicate?

647