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
What is the use of a ‘ ’ character?
how can use subset in c program and give more example
What is %d called in c?
What are static variables in c?
How can I get the current date or time of day in a c program?
Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?
What is the process of writing the null pointer?
FILE *fp1,*fp2; fp1=fopen("one","w") fp2=fopen("one","w") fputc('A',fp1) fputc('B',fp2) fclose(fp1) fclose(fp2)} a.error b. c. d.
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.
Explain how can type-insensitive macros be created?
What is the use of clrscr?
What is strcpy() function?
How do you define a string?
What is structure pointer in c?
Can you define which header file to include at compile time?