Showing posts with label Calculate. Show all posts
Showing posts with label Calculate. Show all posts

C++ Program to calculate simple interest.

C++ Program to calculate simple interest.



#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c,d,e;
cout<<"Enter principal: ";
cin>>a;
cout<<"Enter rate% : ";
cin>>b;
cout<<"Enter time in years: ";
cin>>c;
a=a*b*c/100;
cout<<"The simple interest is: "<<a;
getch();
}

C++ Program to calculate a^b.

C++ Program to calculate a^b.



#include<iostream.h>
#include<conio.h>
int pwr(int,int);
void main()
{
clrscr();
int a,d;
cout<<"Enter first number: ";
cin>>a;
cout<<"Enter second number: ";
cin>>d;
cout<<"A^B: "<<pwr(a,d);
getch();
}

pwr(int a,int d)
{
int i,b=1;
for(i=1;i<=d;i++)
b=b*a;
return b;
}