You are on page 1of 6

Submitted To: Sir Naveed Yasir

Submitted By: M. Rehan Tariq


Subject Of: Programming Fundamentals
Campus Name: UON (OLD Campus)
Semester: First Semester BS CS (Evening)

Assignment Of PROGRAMMING FUNDAMENTALS

Calculator made in C++ Using


Function

MUHAMMAD REHAN
How To Code A Calculator Using Function:
#include<iostream>
#include<math.h>
Using namespace std;
int function(a,b){return(a*b);}
\\here we put the function of subtraction;
int sub(){int a,b;
cout<<“Enter your First And Second Number”<<endl;
cin>>a>>b;
cout<<“Subtraction of the given numbers is: ”<<a-b<<endl;}
\\here we put the function of addition;
int add(){int a,b;
cout<<“Enter your First And Second Number”<<endl;
cin>>a>>b;
cout<<“Addition of the given numbers is: ”<<a+b<<endl;}

MUHAMMAD REHAN
\\here we put the function of Multiplication;
int prod(){int a,b;
cout<<“Enter your First And Second Number”<<endl;
cin>>a>>b;
cout<<“Product of the given numbers is: ”<<a*b<<endl;}
\\here we put the function of Division;
int div(){int a,b;
cout<<“Enter Numenator And Denomenator”<<endl;
cin>>a>>b;
cout<<“Division of the given numbers is: ”<<a/b<<endl;}
\\here we put the function of Cube;
int cube(){int a;
cout<<“Enter your Number”<<endl;
cin>>a;
cout<<“Cube of the given number is: ”<<a*a*a<<endl;}

MUHAMMAD REHAN
\\here we put the function of Square;
int squar(){int a;
cout<<“Enter your Number”<<endl;
cin>>a;
cout<<“Square of the given number is: ”<<a*a<<endl;}
\\here we put the function of Multiplication;
int prod(){int a,b;
cout<<“Enter your First And Second Number”<<endl;
cin>>a>>b;
cout<<“Product of the given numbers is: ”<<a*b<<endl;}
\\here we put the functions of Trignometry;
int trigonometric(){int a,b;
cout<<"Enter Angle of Sin In Degree "<<endl;
cin>>a;
b = sin(a);
cout<<" Your Sin"<<a<<" = "<<b<<endl;}
MUHAMMAD REHAN
int cos(){int a,b;
cout<<"Enter Angle of Cos in Degree "<<endl;
cin>>a;
b = cos(a);
cout<<"Your cos"<<a<<" = "<<b<<endl;}
int tan(){int a,b;
cout<<"Enter Tan angle in Degree: "<<endl;
cin>>a;
b = tan(a);
cout<<"Your tan"<<a<<" = "<<b<<endl;}

int main(){int o;
cout<<"Select Any Operation "<<endl;
cout<<"Enter 1 for Sum "<<endl;
cout<<"Enter 2 for Product "<<endl;
cout<<"Enter 3 for Division "<<endl;
cout<<"Enter 4 for Subtraction "<<endl;
cout<<"Enter 5 for Square "<<endl;
MUHAMMAD REHAN
cout<<"Enter 6 for Cube "<<endl;
cout<<"Enter 7 for Sin function Value:"<<endl;
cout<<"Enter 8 for Cos function Value: "<<endl;
cout<<"Enter 9 for tan function Value: "<<endl;
cin>>o;
if(o == 1){add();}
else if(o == 2){prod();}
else if(o == 3){div();}
else if(o == 4){sub();}
else if(o == 5){squar();}
else if(o == 6){cube();}
else if(o == 7){trigonometric();}
else if(o == 8){cos();}
else if(o == 9){tan();}
return 0;}

THE MUHAMMAD REHAN

You might also like