Guess the output

View previous topic View next topic Go down

Guess the output

Post by Admin on Fri Jun 26, 2015 11:25 pm

#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

Admin
Admin

Posts : 22
Points : 5354
Join date : 2015-06-24
Age : 23

http://csenpsb.createforum.in

Back to top Go down

Re: Guess the output

Post by K.Abirami on Sat Jun 27, 2015 11:42 am

option b

K.Abirami

Posts : 2
Points : 5287
Join date : 2015-06-27
Age : 22
Location : chennai

Back to top Go down

Re: Guess the output

Post by Admin on Sat Jun 27, 2015 12:30 pm

K.Abirami wrote:option b

Nice try abirami, but can you explain the logic for choosing the option??

Admin
Admin

Posts : 22
Points : 5354
Join date : 2015-06-24
Age : 23

http://csenpsb.createforum.in

Back to top Go down

Re: Guess the output

Post by K.Abirami on Sat Jun 27, 2015 12:38 pm

already inputs where given ila.so i thought it will print a,b and c value as we given

K.Abirami

Posts : 2
Points : 5287
Join date : 2015-06-27
Age : 22
Location : chennai

Back to top Go down

Re: Guess the output

Post by Admin on Sat Jun 27, 2015 12:56 pm

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.

Admin
Admin

Posts : 22
Points : 5354
Join date : 2015-06-24
Age : 23

http://csenpsb.createforum.in

Back to top Go down

Re: Guess the output

Post by Admin on Mon Jun 29, 2015 6:19 pm

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..

Admin
Admin

Posts : 22
Points : 5354
Join date : 2015-06-24
Age : 23

http://csenpsb.createforum.in

Back to top Go down

reply

Post by sreenivas_srevs on Sat Jul 04, 2015 7:15 pm

option C ba Razz xD

sreenivas_srevs

Posts : 3
Points : 5295
Join date : 2015-06-26

Back to top Go down

Re: Guess the output

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum