﻿ Practice programing in C++ About  Contact

# Practice some C++ Programs

Q5.Write a C++ program to accept principal, rate of interest and time the find compound interest, simple interest and their difference.
Q6.Write a C++ program to evaluate the expression - Take the values of the variables x, y, z as input
Q7.Write a C++ program to evaluate the following expression. We have to learn some mathematical functions before doing such programs
 pow(x,y) xy Evaluates x to the power y. e.g for 28 we have to write pow(2,8), returned value is double type pow10(x,y) xy Evaluates 10 to the power x, x is an integer, returned value is double type sqrt(x) √ x Evaluates square root of x, x must be >=0, returned value is double type exp(x) ex Evaluates exponent of x, returned value is double type sin(x), cos(x), sec(x) sin(x), cos(x), tan(x) Evaluates sin(x), cos(x), tan(x). Here x is in radian (double), returned value is double type fabs(x) |x| Evaluates absolute value of x, x is double type, returned value is double type abs(x) |x| Evaluates absolute value of x, x is an integer, returned value is integer type log(x) logex evaluates natural log of x, returned value is double type log10(x) log10x Evaluates log of x with base 10, returned value is double type
All the Mathematical functions are defined in the header file "math.h". So do not forget to include this header file in order to use any of these functions.
Program-5
```#include <iostream.h>
#include <math.h>
void main(){
float p, r, t, si, ci, diff;
cout<<"Enter Principal:";
cin>>p;
cout<<"Enter Rate of Interest:";
cin>>r;
cout<<"Enter Time in years:";
cin>>t;
si=a*b*c/100;
ci=p*pow(r/100, t)- p;
diff=ci-si
cout<<"Simple Interest="<<si<<"\n";
cout<<"Compound Interest="<<ci<<"\n";
cout<<"Difference="<<diff<<"\n";
}
```
Program-6
```#include <iostream.h>
#include <math.h>
void main(){
float x, y, z, result;
cout<<"Enter value of x:";
cin>>x;
cout<<"Enter value of y:";
cin>>y;
cout<<"Enter value of z:";
cin>>z;
result=pow(x,4)+ sqrt(y*y + z*z)/(y-z);
}
```

Program-7
```#include <iostream.h>
#include <math.h>
void main(){
float a, b, x, y, result;
cout<<"Enter value of a:";
cin>>a;
cout<<"Enter value of b:";
cin>>b;
cout<<"Enter value of x:";
cin>>x;
cout<<"Enter value of y:";
cin>>y;
result=fabs(a-b)*pow(a,exp(x-1)+pow((pow(x, 1/4)+pow(y, 1/7)), 1/4); 