In: Computer Science
code:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void choice()
{
cout << "Press 1 for calculating sine value of a
Number\n";
cout << "Press 2 for calculating cos value of a
Number\n";
cout << "Press 3 for calculating tangent value of a
Number\n";
cout << "Press 4 for calculating square value of a
Number\n";
cout << "Press 5 for calculating absolute value of a
Number\n";
cout << "Press 6 for calculating round value of a
Number\n";
cout << "Press 7 for calculating truncated value of a
Number\n";
cout << "Press 8 for calculating Floor value of a
Number\n";
cout << "Press 9 for calculating ceil value of a
Number\n";
cout << "Press 10 for calculating log value of a
Number\n";
cout << "Press 11 to exit\n";
}
void operation(int cho,int a)
{
switch(cho){
case 1:
{
cout << "Sine value is " << sin(a) << endl;
break;
}
case 2:
{
cout << "Cosine value is " << cos(a) <<
endl;
break;
}
case 3:
{
cout << "Tangent value is: " << tan(a) <<
endl;
break;
}
case 4:
{
cout << "Square root is : " << sqrt(a) <<
endl;
break;
}
case 5:
{
cout << "Absolute value is: " << abs(a) <<
endl;
break;
}
case 6:
{
cout << "Round value is : " << round(a) <<
endl;
break;
}
case 7:
{
cout << "Truncated value is: " << trunc(a) <<
endl;
break;
}
case 8:
{
cout << "Floor value is : " << floor(a) <<
endl;
break;
}
case 9:
{
cout << "Ceiling value is: " << ceil(a) <<
endl;
break;
}
case 10:
{
cout << "Log value : " << log(a) << endl;
break;
}
case 11:
{
cout<<"Wrong input";
}
}}
int main()
{
int a;
int cho;
choice();
cout<<"Enter choice :";
cin>>cho;
cout<<"Enter value: ";
cin>>a;
operation(cho,a);
return 0;
}
output:
we can also change the datatype of the number;
thankyou