Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.


Please wait...

C Programming :: Control Instructions

3. What is the output of the following 'C' program?

#include
void main()
{
int i=10,j=20;
j=i,j?(i,j)?i:j:j;
printf("%d %d",i,j);
}

Answer: Option A

Explanation :

  1. notice the comma operator when variables are separated by them they are evaluated from left to right and only last value is considered ( it has less precedence than assignment operator)
    so due to the precedence of assignment being high the assignment is done first and then comma operator is evaluated be the expression finally evaluates to j=i,(j?(i,j)?i:j:j);
  2. so the value of i is assigned to j
    you can run the same program  with one more variable C the value of j will be equal to the value of C as per above logic

#include

void main()

{

int i=10,j=20;

int c=10000;

j=c,j?(i,j)?i:j:j;

printf("%d %d",i,j);

}


Post Your Answer Here:     

q4i-reply-your-answer Reply     |    Rate This: +0 -0      |     Report     |     To Reading List



Report Error

Please Login First Click Here