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
* / % + - =
= * / % + -
/ * % - + =
* % / - + =
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.

Tillu said:   7 years ago
@Team Bi.

int a=2,b=3,c;
a=(b++)+(++b)+a;
c=a>b?a:b;
b=(a++)+(b--)+a;
c=c++*b--

The value of a=11, b=25, c=260.

Bagavathi said:   8 years ago
Answer of c+=(a>0&&a<=10)?++a:a/b;a=50;b=10;c=20;

Team BI said:   8 years ago
int a=2,b=3,c;
a=(b++)+(++b)+a;
c=a>b?a:b;
b=(a++)+(b--)+a;
c=c++*b--

Find the final values of a, b and c.

Harpreet Singh said:   8 years ago
If a=48, b=13; find a+=b++*5/a++ +b.

Nilay tagde said:   8 years ago
When this *for*loop will terminate?
for(a=1;scanf("%d",&a);a++)
printf("%d",a);

Shishir said:   8 years ago
How y=a++differs from y=++a if value of a is 5?

Kamlesh yadav said:   8 years ago
int x=3,y,z;
z=y=x;
z=y+=x=-z;
printf("%d%d%d",x,y,z);

For this code, I get the output as -3 0 0.
But, I can't understand the real execution.
Anyone can explain?

Priyanka said:   8 years ago
if((i==j||i+j==a+1)&&(i!=1&&i!=a)&&(j!=1&&j!=a)&&(i!=1&&j!=1))

Can anyone plz explain this logic why we use this kind of logic? I cannot understand this.

Zee khan said:   8 years ago
The above program or logical operation output is 35 because prefix first increment then print and postfix first print then increment. They use one postfix and two prefix.

Maninderpreet said:   8 years ago
#include<stdlib.h>
#include<stdio.h>
void main()
{
int a=10, i;
a=i++ + i++ + ++i + ++i;
printf("%d",a);
}

Output: 40

Can anyone help in understanding the code?


Post your comments here:

Your comments will be displayed after verification.