C Programming - Expressions - Discussion
Discussion Forum : Expressions - General Questions (Q.No. 1)
1.
Which of the following is the correct order of evaluation for the below expression?
z = x + y * z / 4 % 2 - 1
z = x + y * z / 4 % 2 - 1
Answer: Option
Explanation:
C uses left associativity for evaluating expressions to break a tie between two operators having same precedence.
Discussion:
92 comments Page 3 of 10.
Sorna said:
8 years ago
@ALL.
#include<stdio.h>
int main()
{
int a=5;
int b=++a*a++;
printf("%d",b);
return 0;
}
Answer is 36.
#include<stdio.h>
int main()
{
int a=5;
int b=++a*a++;
printf("%d",b);
return 0;
}
Answer is 36.
Chris said:
8 years ago
According to me, it is;
int main().
int a=5
Int b=++a*a++
Print(%d,b)
int main().
int a=5
Int b=++a*a++
Print(%d,b)
Rajoo said:
8 years ago
Anybody, explain me the answer of this question. please.
Rakesh kumar said:
8 years ago
@Jaya.
a=4;
Printf("...d",a=a++)
Ans- here a++ is in post increment that's why it will change its value in next step but here there is no any next step that's what it will print the original value of a which is 4.
And in Printf(",,...d",a).
There is no any condition for value change so it will print its real value which is 4.
That's why both answers will be 4
a=4;
Printf("...d",a=a++)
Ans- here a++ is in post increment that's why it will change its value in next step but here there is no any next step that's what it will print the original value of a which is 4.
And in Printf(",,...d",a).
There is no any condition for value change so it will print its real value which is 4.
That's why both answers will be 4
Garima said:
8 years ago
% /*+-= is hierchie.
Jay Mehta said:
8 years ago
#include<stdio.h>
int main()
{
int a=5;
int b=++a*a++;
printf("%d",b);
return 0;
}
Can anyone tell me the answer of this?
int main()
{
int a=5;
int b=++a*a++;
printf("%d",b);
return 0;
}
Can anyone tell me the answer of this?
Ambrisha srivastava said:
7 years ago
Here;
int a=14,b;
b=(++a)+(a++)+(--a);
Give the value of a,b;
I got the outpu 45, other PC 42 .
Please explain to me.
int a=14,b;
b=(++a)+(a++)+(--a);
Give the value of a,b;
I got the outpu 45, other PC 42 .
Please explain to me.
TEDD said:
2 months ago
BODMAS meaning.
B = BRACKETS
O = ORDERS/ EXPONENTIAL
D = DIVISION
M = MULTIPLICATION
A = ADDITIONS
S = SUBTRACTION
B = BRACKETS
O = ORDERS/ EXPONENTIAL
D = DIVISION
M = MULTIPLICATION
A = ADDITIONS
S = SUBTRACTION
Vaishali said:
6 years ago
@Mauli.
For your program.
The execution like this,
1) b+=++a which is equal to b=b+ ++a i.e b=20+11=31(stored in memory b=31 and a=11)
2) ++b=32( stored in memory).
3) a++=11( a=12 stored in memory now).
4) a+=b++ which is equal to a=a+ b++ i.e a=12+ 32=44( stored in memory a=44 and b=33 Because b++ is 1st assign then store in memory).
So the output is b=33 and a=44.
For your program.
The execution like this,
1) b+=++a which is equal to b=b+ ++a i.e b=20+11=31(stored in memory b=31 and a=11)
2) ++b=32( stored in memory).
3) a++=11( a=12 stored in memory now).
4) a+=b++ which is equal to a=a+ b++ i.e a=12+ 32=44( stored in memory a=44 and b=33 Because b++ is 1st assign then store in memory).
So the output is b=33 and a=44.
Jahnavi said:
6 years ago
In don't understand the answer can anyone please explain it clearly?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers