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?

Long Answer
Views 2428

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;
}

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of C Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.