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;
}
}

Answer Posted / raja

In the following code snippet
#include <stdio.h>
Main()
{
Int x=4;
While(x==1)
{
X=x-1;
Printf(“%d”,x);
--x;
}
}
everything is fine except the typing mistake. C is a case sensitive language. So if u give Main instead of main u will get a compiler error. So Main, Int, While, Printf should be use as a main, int, while, printf and the X in line 7 should be x.
The correct program is
#include <stdio.h>
main()
{
int x=4;
while(x==1)
{
x=x-1;
printf("%d",x);
--x;
}
}
Nothing will get printed because x != 1

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between Function to pointer and pointer to function

621


Why & is used in c?

698


How do I round numbers?

587


Explain what are linked list?

611


What is meant by operator precedence?

662






What is line in c preprocessor?

604


What does %2f mean in c?

668


Suggesting that there can be 62 seconds in a minute?

588


How is a structure member accessed?

574


How many loops are there in c?

569


Define VARIABLE?

679


write a program which the o/p should b in such a way that s triangle if I/p is 3,a Square/rectangle if I/P=4,a pentagon if I/P=5 and so on...forget about the I/P which is less than 3

1630


What are categories used for in c?

552


Explain what does the format %10.2 mean when included in a printf statement?

767


What is the maximum length of an identifier?

655