You are on page 1of 8

ASSIGNMENT OF PROGRAMMING FUNDAMENTALS

Submitted by: BCS semester 2 Submitted to:

#include "stdafx.h" #include<conio.h> #include<stdio.h> #include<iomanip> #include<iostream> #include<cmath> #include<math.h> #include "cstdlib" void operation(int); void menu(void); using namespace std; int main() { menu(); return 0; getche(); } void menu(void) { int option; while() { system("cls"); cout<<"Welcome to the Scientific Calculator."<<endl; cout<<"Select an appropiate option from the menu:"<<endl; cout<<setw(10)<<"1.x+y"; cout<<setw(10)<<"2.x-y"; cout<<setw(10)<<"3.x/y"; cout<<setw(10)<<"4.x*y"; cout<<setw(10)<<"5.x%y"; cout<<setw(10)<<"6.ceil(x)"; cout<<setw(10)<<"7.floor(x)"; cout<<setw(10)<<"8.sin(x)"; cout<<setw(10)<<"9.cos(x)"; cout<<setw(10)<<"10.tan(x)"; cout<<setw(10)<<"11.x^2"; cout<<setw(10)<<"12.x^3"; cout<<setw(10)<<"13.x^y"; cout<<setw(10)<<"14.sqrt(x)"; cout<<setw(10)<<"15.log10(x)"; cout<<setw(10)<<"16.ln(x)"; cout<<setw(10)<<"17.e^x";

cout<<setw(10)<<"18.abs(x)"<<endl; cout<<"Additional Functionality"<<endl; cout<< "19. Average of numbers(Enter -1 to end data entry)"<<endl; cout<< "20. Even or Odd(x)"<<endl; cout<< "21. Check Multiple(x,y)"<<endl; cout<< "22. n!"<<endl; cout<< "23. Exit the Calculator"<<endl; cout<<"Enter your option: "<<endl; cin>>option; if(option==23) { break; } operation(option); } } void operation(int option) { switch(option) { case 1: { int x,y; cout<<"Enter the value of x: "; cin>>x; cout<<"Enter the value of y: "; cin>>y; cout<<x+y<<endl; break; } case 2: { int x,y; cout<<"Enter the value of x: "; cin>>x; cout<<"Enter the value of y: "; cin>>y; cout<<x-y<<endl; break; } case 3: { int x,y; cout<<"Enter the value of x: "; cin>>x;

cout<<"Enter the value of y: "; cin>>y; cout<<x/y<<endl; break; } case 4: { int x,y; cout<<"Enter the value of x: "; cin>>x; cout<<"Enter the value of y: "; cin>>y; cout<<x*y<<endl; break; } case 5: { int x,y; cout<<"Enter the value of x: "; cin>>x; cout<<"Enter the value of y: "; cin>>y; cout<<x%y<<endl; break; } case 6: { double x; cout<<"Enter the value of x: "; cin>>x; cout<<ceil(x)<<endl; break; } case 7: { double x; cout<<"Enter the value of x: "; cin>>x; cout<<floor(x)<<endl; break;

} case 8: { double x; cout<<"Enter the value of x: "; cin>>x; cout<<sin(x)<<endl; break; } case 9: { double x; cout<<"Enter the value of x: "; cin>>x; cout<<cos(x)<<endl; break; } case 10: { double x; cout<<"Enter the value of x: "; cin>>x; cout<<tan(x)<<endl; break; } case 11: { double x; cout<<"Enter the value of x: "; cin>>x; cout<<x*x<<endl; break; } case 12: { double x; cout<<"Enter the value of x: "; cin>>x; cout<<x*x*x<<endl;

break; } case 13:

{ double x , y; cout<<"Enter the value of x: "; cin>>x; cout<<"Enter the value of y: "; cin>>y; cout<<pow(x,y)<<endl;

break; } case 14: { double x; cout<<"Enter the value of x: "; cin>>x; cout<<sqrt(x)<<endl;

break; } case 15: { double x; cout<<"Enter the value of x: "; cin>>x; cout<<log10(x)<<endl;

break; } case 16: { double x; cout<<"Enter the value of x: "; cin>>x; cout<<log(x)<<endl;

break; } case 17: { double x; cout<<"Enter the value of x: "; cin>>x; cout<<exp(x)<<endl;

break; } case 18: { double x; cout<<"Enter the value of x: "; cin>>x; cout<<abs(x)<<endl;

break; } case 19: { int x=0,y=0,z=0; do { cout<<"Enter numbers and 0 to quit: "; cin>>x; y++; z+=x; }while(x!=0); z=z/y; cout<<z<<endl; break; } case 20: { int x; cout<<"Enter the value of x: "; cin>>x; if(x%2==0) { cout<<"Even"<<endl; } else { cout<<"Odd"<<endl; } break; } case 21:

{ int x,y; cout<<"Enter the value of x: "; cin>>x; cout<<"Enter the value of y: "; cin>>y; if ((x%y==0)||(y%x==0)) { cout<<"Both are multiples"<<endl; } else { cout<<"Not multiples"<<endl; } break; } case 22: { int x,z=1; cout<<"Enter the value of x: "; cin>>x; for(x;x>0;x--) { z*=x; } cout<<z<<endl; break; } getch(); }

You might also like