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
What are the different properties of variable number of arguments?
What is define directive?
What are conditional operators in C?
Can you write a programmer for FACTORIAL using recursion?
How can you increase the allowable number of simultaneously open files?
Differentiate between Macro and ordinary definition.
What are the similarities between c and c++?
When should the volatile modifier be used?
In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?
7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.
What is strcmp in c?
what is the significance of static storage class specifier?
Why do we use static in c?
What are the 5 organizational structures?
Explain the difference between null pointer and void pointer.