1.exp 2.log 3.log10
4.sqrt 5.sin 6.cos
7.tan
note: use of Switch case for easy coding and choice selection between several option.
Source Code:-
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{clrscr();
int choice;double arg,arg1,arg2,arg3,num,num1,num2;
cout<<"Mathematical Operation by-Tarun Rawat\n";again:
cout<<"\n1=exp (eg:e^2)\n2=log (eg:log(1))";
cout<<"\n3=log10 (eg:log10(1))\n4=sqrt (eg:sqrt(81))\n5=sin\n6=cos\n7=tan\n";
cout<<"\nEnter cHOICE: ";
cin>>choice;
switch(choice)
{case 1: cout<<"\nEnter power of e :";
cin>>arg;
cout<<"\nValue is: "<<exp(arg);break;
case 2: cout<<"\nEnter value of log :";
cin>>num;
cout<<"\nValue is: "<<log(num);break;
case 3: cout<<"\nEnter value of log10 :";
cin>>num1;
cout<<"\nValue is: "<<log10(num1);break;
case 4: cout<<"\nEnter value for sqrt :";
cin>>num2;
cout<<"\nValue is: "<<sqrt(num2);break;
case 5: cout<<"\nEnter value of sin in radian :";
cin>>arg1;
cout<<"\nValue is: "<<sin(arg1);break;
case 6: cout<<"\nEnter value of cos in radian :";
cin>>arg2;
cout<<"\nValue is: "<<cos(arg2);break;
case 7: cout<<"\nEnter value of tan in radian :";
cin>>arg3;
cout<<"\nValue is: "<<tan(arg3);break;
default:cout<<"\nWrong Choice\n";goto again;
}
getch();
}
No comments:
Post a Comment