Guess the output
3 posters
Page 1 of 1
Guess the output
#include<stdio.h>
#include<conio.h>
void main()
{
int a=5,b=6,c=11;
clrscr();
printf("%d %d %d");
getch();
}
What will output when you compile and run the above code?
(a)Garbage value garbage value garbage value
(b)5 6 11
(c)11 6 5
(d)Compiler error
#include<conio.h>
void main()
{
int a=5,b=6,c=11;
clrscr();
printf("%d %d %d");
getch();
}
What will output when you compile and run the above code?
(a)Garbage value garbage value garbage value
(b)5 6 11
(c)11 6 5
(d)Compiler error
Re: Guess the output
option b
K.Abirami- Posts : 2
Points : 22682
Join date : 2015-06-27
Age : 28
Location : chennai
Re: Guess the output
K.Abirami wrote:option b
Nice try abirami, but can you explain the logic for choosing the option??
Re: Guess the output
already inputs where given ila.so i thought it will print a,b and c value as we given
K.Abirami- Posts : 2
Points : 22682
Join date : 2015-06-27
Age : 28
Location : chennai
Re: Guess the output
K.Abirami wrote:already inputs where given ila.so i thought it will print a,b and c value as we given
Good thought, Now copy paste in your IDE and execute the program. And check the output.
Re: Guess the output
Admin wrote:#include<stdio.h>
#include<conio.h>
void main()
{
int a=5,b=6,c=11;
clrscr();
printf("%d %d %d");
getch();
}
What will output when you compile and run the above code?
(a)Garbage value garbage value garbage value
(b)5 6 11
(c)11 6 5
(d)Compiler error
The answer is option c: 11 6 5
Reason: Even if the variables are not provided in the print statement, the program takes the last initialized number for the 1st and second last as 2nd and so on.... so here in this program, c is initialized last so value of c is 11 and 11 gets printed 1st..
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|