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'

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / srsabariselvan3

a=3
b=1
c=1
d=2

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More C Interview Questions

Dear Sir, we are required the bubble sorting programs Regs Prem

1 Answers  


swap 2 numbers without using third variable?

0 Answers   IBS,


Is null always defined as 0(zero)?

0 Answers  


what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values

0 Answers   College School Exams Tests,


Explain what are the different data types in c?

0 Answers  






which type of question asked from c / c++ in interview.

2 Answers  


i have a written test for microland please give me test pattern

0 Answers   Microland,


Write a program to generate the Fibinocci Series

0 Answers   TISL,


who invented c

13 Answers   IBM,


a linear linked list such that the link field of its last node points to the first node instead of containing NULL a) linked list b) circular linked list c) sequential linked list d) none

0 Answers  


difference between native and cross compilers

0 Answers  


What does printf does?

0 Answers  


Categories