a=(1,2,3);
b=1,2,3;
c=1,(2,3);
d=(1,2),3;
what's the value of 'a','b','c','d'

Answer Posted / vadivelt

3 1 1 2.

To analyse, lets rewrite the prgm.

#include<stdio.h>
#include<conio.h>
main()
{
int a, b, c, d;
a = (1,2,3);
b = 1,2,3;
c = 1,(2,3);
d = (1,2),3;
printf("%d %d %d %d", a, b, c, d);
getch();
}


Note:Precedence of evaluation of the statements would be:
for (1,2,3) it is -> ie., left to right
for 1,2,3 it is <- ie., right to left.

Now,
1. In statement a = (1,2,3); due to the precedence(->)
latest vale of a would be 3.

2. In the same way( <- ) in the statement b = 1,2,3; latest
value of b would be 1.

In statement c = 1,(2,3); and d = (1,2),3; there are two
precedency lavel.

Lets analyse.

3.In c = 1,(2,3); As we know the basic rule in C that the
expression in a statement with braces evaluated first. So
the outcome of (2,3) would be 3(cos., ->), then the
statement c = 1,(2,3); shall be replaced as c = 1, 3; in
runtime. So in the next execution c's latest value would be
1. Cos now precedence would be <-.

4. In the same way, first d = (1,2),3; will be replaced as
d = 2,3 then d holds the value 2 as latest value.

Is This Answer Correct ?    11 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which is better oop or procedural?

622


What are valid operations on pointers?

662


What is ctrl c called?

586


If null and 0 are equivalent as null pointer constants, which should I use?

573


write a c program to calculate sum of digits till it reduces to a single digit using recursion

2712






What is a sequential access file?

644


How many identifiers are there in c?

573


in iso what are the common technological language?

1627


Which header file should you include if you are to develop a function which can accept variable number of arguments?

797


Why is structure important for a child?

601


What is action and transformation in spark?

589


What is #error and use of it?

670


Explain how can I make sure that my program is the only one accessing a file?

614


What is the purpose of sprintf?

611


find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

1522