GeekInterview.com
Series: Subject: Topic:
Question: 4 of 238

Whats the output of.....>>?

#include #include void main() { int a=1; if(a=1,3,5,6) printf("good&a=%d",a); else printf("bad&a=%d",a); } }
Asked by: geekaayuush | Member Since Sep-2012 | Asked on: Sep 7th, 2012

View all questions by geekaayuush

Showing Answers 1 - 5 of 5 Answers
mohan

Answered On : Oct 5th, 2012

good&a=1

  
Login to rate this answer.
jbode

Answered On : Oct 8th, 2012

View all answers by jbode

The resulting output is "good&a = 6".

Reason: the result of the expression 1,3,5,6 is 6, which is assigned to a as part of the condition. Since 6 is non-zero, the first branch is taken.

Read up on the comma operator for details.

  
Login to rate this answer.
udit

Answered On : Oct 31st, 2012

good&a=1

  
Login to rate this answer.
rahul jadhav

Answered On : Nov 21st, 2012

good&a=1

  
Login to rate this answer.
FahadFirozKhan

Answered On : Jan 23rd, 2013

error: #include expects "FILENAME" or
error: expected identifier or { before } token

#include

void main()
{
int a=1;
if(a=1,3,5,6)
printf("good&a=%d",a);
else
printf("bad&a=%d",a);

}

//Output

good&a=1

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.