DMAS by function | use of function

#include <iostream>
using namespace std;

// all thefunction are called in this parts

int sum ();
int minus();
int multiply();
int divide ();


void main()

{
// declare the varible as the return value of functions

int result1=sum();
int result2=minus();
int result3=multiply();
int result4=divide();

cout<<"\n:Summary of the Results:";
cout<<"The sum is: "<<result2<<endl;
cout<<"The subtaction is:"<<result2<<endl;
cout<<"The Multiply is:"<<result3<<endl;
cout<<"The Divide is:"<<result4<<endl;
}

int sum ()
{


int a;
int b;

cout<<"For Addition"<<endl;

cout<<"Please enter the value for a: ";
cin>>a;
cout<<"Please enter the value for b: ";
cin>>b;

int sum=a+b;

cout<<"result is: "<<sum<<endl;


return sum ;
}

int minus ()
{

cout<<"For Subtraction"<<endl;
int a;
int b;

cout<<"Please enter the value for a: ";
cin>>a;
cout<<"Please enter the value for b: ";
cin>>b;

int minus=a-b;
cout<<"result is: "<<minus<<endl;

return minus ;
}

int multiply ()
{

int a;
int b;

cout<<"For Mutiplication"<<endl;

cout<<"Please enter the value for a: ";
cin>>a;
cout<<"Please enter the value for b: ";
cin>>b;

int multiply=a*b;

cout<<"result is: "<<multiply<<endl;
return multiply ;
}


int divide ()
{

int a;
int b;



cout<<"For division"<<endl;
cout<<"Please enter the value for a: ";
cin>>a;
cout<<"Please enter the value for b: ";
cin>>b;

int divide=a/b;

cout<<"result is: "<<divide<<endl;
return divide ;
}

Comments

Popular posts from this blog

Umbrella activities in Software Engineering

Operating System | Best Definition of Opetating System