Saturday, 18 February 2017

C+ program, Functions of exponential, increment and addition

#include <iostream>
#include <conio.h>

using namespace std;

int expo(int a, int b);

int inc(int x);

int add(int a, int b);

int main()

{
int num,x;
cout<<"Enter Number for exponential"<<endl;
cin>>num;
cout<<"Enter Power of exponential"<<endl;
cin>>x;
cout<< "Exponential of " <<num<<" is "<<expo(num,x)<<endl;
cout<<"Increament of "<<x<<" is "<<inc(x)<<endl;
cout << "Addition of "<<num<<" and "<<x<<" is "<< add(num,x);
getch();
}

int add(int a, int b)

{
int ans=0;
ans=a+b;
return ans;
}


int inc(int x)

{
x=x+1;
return x;
}



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



Share:

0 comments:

Post a Comment