What value will be assigned to the variable X if a = 10, b = 20, c = 30, d = 40 for the expression X = a/b+c*d-c?

C Programming Language >   Operators and Enums in C Language >   Introduction to Operator  

Short Question

2549


Answer:

  • The above arithmetic operation is performed based on the precedence of the operators.
  • In above mentioned expression, c*d will be performed first. Then, a/b, then (c*d)-c, then (a/b) + ((c*d)-c).
  • Please check the operator precedence table to know the priority and associativity of the C operators.
  • Output of the above expression is 1170.


2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
   int a = 10, b = 20, c = 30, d = 40, X ;
 
   X = a/b+c*d-c;
   printf(" Value of X = %d\n", X);
   return 0;
}


This Particular section is dedicated to Question & Answer only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.




Join Our telegram group to ask Questions

Click below button to join our groups.