C+ program, Functions of exponential, increment and addition

In this program we will find exponential, increment and addition through a function.

//Code starts

#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;

}

//Code Ends

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s