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;
}
}
Answers were Sorted based on User's Feedback
Answer / rohit
variable X have not been defined. so it has an error...........
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / 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 |
Answer / bhavani
i think x initialization wrong.so it has an error...........
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / satya
Ya.. it is correct...
you initialized the x as Int..
we have to to initialize it as int...
| Is This Answer Correct ? | 0 Yes | 0 No |
i want to know aptitude questions,technical questions
Add Two Numbers Without Using the Addition Operator
write the program for maximum of the following numbers? 122,198,290,71,143,325,98
How can I do serial ("comm") port I/O?
Difference between C and Embedded C?
What is this infamous null pointer, anyway?
c program to subtract between two numbers without using '-' sign and subtract function.
What does the file stdio.h contain?
Is python a c language?
What does %d do in c?
void main() { static int i = 5; if(--i) { main(); printf("%d ",i); } } what would be output of the above program and justify your answer? }
5 Answers C DAC, CDAC, Infosys, Wipro,
write a c program to find largest of three numbers using simple if only for one time.