Mathematical expressions in C language

  • on February 4, 2019
  • Likes!

Program to evaluate the mathematical expressions in c language. You can use this program both error(compiler and runtime error) free programs just copy and paste the programs and save your time.

How to solve the following mathematical expressions in C language and result store in float type of variable.
   1. a+b-(c+d)*3/e+f/9)  
   2. a/4-b/2+(c*d-5)/e

Result Store in float type of variable up to 6th decimal place

#include<conio.h>
#include<math.h>
void main()
{
int a,b,c,d,e,f;
float result;
a=8, b=4, c=2, d=1, e=5, f=20;
//evaluate the frist expression
result= a+b-(c+d)*3/e+f/9;
printf(“The Result of Frist mathimatical Expression is: %fn”, result);
a=17, b=5, c=6, d=3, e=5;
//evaluate the second expression
result= a/6-b/2+(c*d-5)/e;
printf(“And Result of Second mathimatical expression is: =%fn”,result);
getch();
Output:
The Result of Frist mathematical Expression is: 12.422222
And Result of Second mathematical expression is: 2.933333

Note:– This program evaluates the mathematical expressions according to math rule of BDMAS so to check output is correct or not solve the on paper according to mathematical rule on BODMAS rule. I am sure to this program code is correct.

Result Store in float type of variable up to 2nd decimal place

#include<conio.h>
#include<math.h>
void main()
{
int a,b,c,d,e,f;
float result;
a=8, b=4, c=2, d=1, e=5, f=20;
//evaluate the frist expression
result= a+b-(c+d)*3/e+f/9;
printf(“The Result of Frist mathimatical Expression is: %0.2fn”, result);
a=17, b=5, c=6, d=3, e=5;
//evaluate the second expression
result= a/6-b/2+(c*d-5)/e;
printf(“And Result of Second mathimatical expression is: =%0.2fn”,result);
getch();
}
Output:
The Result of Frist mathematical Expression is: 12.42
And Result of Second mathematical expression is: 2.93

Note: float type of variable store by default and maximum  up to 6th decimal place if you can customize like “0.2f”

I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any dought about this c programming code or input & output please comment below
If you have other question about c programming send an email by contacting us form are given on page right side.
Thank You!

Article Categories:
Programs in c

Leave a Reply

Your email address will not be published. Required fields are marked *