Dark mode logo
Last Updated:
Evaluate an expression in C

C Program to evaluate an expression

Note: This program is used to evaluate the expression ((a - b) / c * d + e) + (f + g);

Algorithm

Input: Input a,b,c,d,e,f,g
output: The expression is evaluated

  1. Start
  2. Input a,b,c,d,e,f,g
  3. val = ((a-b)/c*d+e)+(f+g)
  4. Print val
  5. Stop

C Program

 

#include <stdio.h>
int main( )
{
   int a, b, c, d, e, f, g, val;
    printf("Enter first number: ");
    scanf("%d", &a);
    printf("Enter second number: ");
    scanf("%d", &b);
    printf("Enter third number: ");
    scanf("%d", &c);
    printf("Enter forth number: ");
    scanf("%d", &d);
    printf("Enter fifth number: ");
    scanf("%d", &e);
    printf("Enter sixth number: ");
    scanf("%d", &f);
    printf("Enter seventh number: ");
    scanf("%d", &g);
    val = ((a - b) / c * d + e) + (f + g);
    printf("The expression evaluated and the value is %d", val);
   return 0;
}
 
Note: This Program was created using visual studio code. The Program file can be downloaded by clicking here

Comments