Arithmeatic Expression 01 || Use of Various Operators ||C++

In this, we are going to  solve an arithmetic expression with the help of C++ program.

Eg :
a + b * (c - d)/e 
This is an arithmetic expression which can be solved if we have the values of a, b, c, d, and e.

We will solve it using C++

The Code given below can be used in Turbo C++ Compiler.

// arithematic expression program
#include<iostream.h>
#include<conio.h>
#include<math.h>

void main()
{
    clrscr();
    float a = 10.5;
    int b = 8;
    int c = 3;
    float d = 29.8;
    float e = 25.4;
    double f = sqrt( ( a * (b % c) + d) / e ); 
    cout<<"sqrt( ( a * (b % c) + d) / e ) = "<<f;
    getch();
}

  

The Code given below can be used in g++/gcc Compiler.

// arithematic expression program
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    float a = 10.5;
    int b = 8;
    int c = 3;
    float d = 29.8;
    float e = 25.4;
    double f = sqrt( ( a * (b % c) + d) / e ); 
    cout<<"sqrt( ( a * (b % c) + d) / e ) = "<<f;
    return 0;
}
  
  
#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post