Logical Analysis and Programming
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Guess the output

3 posters

Go down

Guess the output Empty Guess the output

Post by Admin 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 : 22749
Join date : 2015-06-24
Age : 29

https://csenpsb.board-directory.net

Back to top Go down

Guess the output Empty Re: Guess the output

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

option b

K.Abirami

Posts : 2
Points : 22682
Join date : 2015-06-27
Age : 28
Location : chennai

Back to top Go down

Guess the output Empty Re: Guess the output

Post by Admin 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 : 22749
Join date : 2015-06-24
Age : 29

https://csenpsb.board-directory.net

Back to top Go down

Guess the output Empty Re: Guess the output

Post by K.Abirami 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 : 22682
Join date : 2015-06-27
Age : 28
Location : chennai

Back to top Go down

Guess the output Empty Re: Guess the output

Post by Admin 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 : 22749
Join date : 2015-06-24
Age : 29

https://csenpsb.board-directory.net

Back to top Go down

Guess the output Empty Re: Guess the output

Post by Admin 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 : 22749
Join date : 2015-06-24
Age : 29

https://csenpsb.board-directory.net

Back to top Go down

Guess the output Empty reply

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

option C ba Razz xD

sreenivas_srevs

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

Back to top Go down

Guess the output Empty Re: Guess the output

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


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