Â
In this, we are going to get values of variables in the arithmetic expression from user in a C++ program.
We will solve it using C++
The Code given below can be used in Turbo C++ Compiler.
// arithematic expression program with user input #include<iostream.h> #include<conio.h> #include <math.h> void main() { clrscr(); float a; int b; int c; float d; float e; cout<<"Taking values of variables in expression :\n"; cout<<"Enter floating value for a\n"; cin>>a; cout<<"Enter integer value for b\n"; cin>>b; cout<<"Enter integer value for c\n"; cin>>c; cout<<"Enter floating value for d\n"; cin>>d; cout<<"Enter floating value for e\n"; cin>>e; double f = sqrt( ( a / (b % c) - d) * e ); cout<<"sqrt( ( a / (b % c) - d) * e) = "<<f; getch(); }
#include <iostream>
#include <math.h>
using namespace std;// arithematic expression program with user input
int main()
{
float a;
int b;
int c;
float d;
float e;
cout<<"Taking values of variables in expression :\n";
cout<<"Enter floating value for a\n";
cin>>a;
cout<<"Enter integer value for b\n";
cin>>b;
cout<<"Enter integer value for c\n";
cin>>c;
cout<<"Enter floating value for d\n";
cin>>d;
cout<<"Enter floating value for e\n";
cin>>e;
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