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 2 of 10.
Zee khan said:
9 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:
9 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?
#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?
Anjaneyagouda said:
9 years ago
If a=i*(j/=k/i) if a=5, i=2, j=3, k=4, how to solve this?
Babatunde said:
9 years ago
a = 1; a = a++; What is the current value of a?
Shahab said:
9 years ago
I have a question what will be this program output? Can anyone tell me?
#include <stdio.h>
int main()
{
int a = 2, b= 5, c = 10;
int x = 3, y = 6;
int res1 = a * b++ - (a * ++c) % b-- + c++ * a++;
int res2 = x++ * ++y;
printf("%d\n", res1);
printf("%d\n", res2);
return 0;
#include <stdio.h>
int main()
{
int a = 2, b= 5, c = 10;
int x = 3, y = 6;
int res1 = a * b++ - (a * ++c) % b-- + c++ * a++;
int res2 = x++ * ++y;
printf("%d\n", res1);
printf("%d\n", res2);
return 0;
Adi said:
9 years ago
What is the output of the following program?
void f1(){
static int s=5;
++s;
printf("%d",s);
}
main(){
f1();
f1();
printf("%d",s);
void f1(){
static int s=5;
++s;
printf("%d",s);
}
main(){
f1();
f1();
printf("%d",s);
Sriramprashad said:
9 years ago
Evaluate the following expression according to hierarchical rule, so the order of the evaluation and find the resultant data type of the expression.
int x= 2, y=30;
long l=10000;
double d=8.500;
x++ - (y-- /10) * ++x%y +l -(l+d,x--,++y) +!(d);.
int x= 2, y=30;
long l=10000;
double d=8.500;
x++ - (y-- /10) * ++x%y +l -(l+d,x--,++y) +!(d);.
Nilay tagde said:
9 years ago
When this *for*loop will terminate?
for(a=1;scanf("%d",&a);a++)
printf("%d",a);
for(a=1;scanf("%d",&a);a++)
printf("%d",a);
ANEESH said:
9 years ago
Can you explain it?
int main (void)
{
float a;
int q;
printf("\nInsert number\t");
scanf("%f",&a);
q=(int)a;
++q;
if((q - a) != 1)
printf("\nThe number is not an integer\n\n");
else
printf("\nThe number is an integer\n\n");
return 0;
}
int main (void)
{
float a;
int q;
printf("\nInsert number\t");
scanf("%f",&a);
q=(int)a;
++q;
if((q - a) != 1)
printf("\nThe number is not an integer\n\n");
else
printf("\nThe number is an integer\n\n");
return 0;
}
ANEESH said:
9 years ago
Please expalin me q=int(a); expression.
int main (void)
{
float a;
int q;
printf("\nInsert number\t");
scanf("%f",&a);
q=(int)a;
++q;
if((q - a) != 1)
printf("\nThe number is not an integer\n\n");
else
printf("\nThe number is an integer\n\n");
return 0;
}
int main (void)
{
float a;
int q;
printf("\nInsert number\t");
scanf("%f",&a);
q=(int)a;
++q;
if((q - a) != 1)
printf("\nThe number is not an integer\n\n");
else
printf("\nThe number is an integer\n\n");
return 0;
}
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers