Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* involves exclusively outline functions
- 1.Passing of values from the main function to the sub function
- and calling of the function
- */
- #include <iostream>
- #include <conio.h>
- #include <math.h>
- using namespace std;
- double cores (double);
- double res (double);
- float sub(float ,float);
- float div(float,float);
- float mul(float,float);
- float add(float,float);
- float ramp(float,float);
- double modulus_(double);
- void menu();
- float a,b,c,ch;
- int ch1;
- int main()
- {
- system("cls");
- menu();
- cin >> ch;
- if (ch == 1)
- {
- c = mul(a, b);
- cout << "the multilication result is" << c;
- }
- else if (ch == 2)
- {
- c = add(a, b);
- cout << "the result is" << c;
- }
- else if (ch == 3)
- {
- c = sub(a, b);
- cout << "the result is" << c;
- }
- else if (ch == 4)
- {
- c = div(a, b);
- cout << "the result is " << c;
- }
- else if (ch == 5)
- {
- cout << "the power is";
- c = ramp(a, b);
- cout << "the result is" << c;
- }
- else if (ch == 6)
- {
- cout << "the modulus o9f the no. is" << endl;
- c = modulus_(a);
- cout << c;
- }
- else if (ch == 7)
- {
- cout << "the cos value is" << endl;
- c = cores(a);
- cout << c;
- }
- else if (ch == 8)
- {
- cout << "the sin value is" << endl;
- c = res(a);
- cout << c;
- }
- else
- {
- cout << "out of credentials sorry";
- }
- system("pause");
- return 0;
- }
- float mul(float x, float y)
- {
- float res;
- res = x*y;
- return (res);
- }
- float add(float x, float y)
- {
- float res;
- res = x + y;
- return (res);
- }
- float sub(float x, float y)
- {
- float res;
- res = x - y;
- return (res);
- }
- float div(float x, float y)
- {
- float res;
- res = x / y;
- return (res);
- }
- float ramp(float x, float y)
- {
- float i, s = 1;
- for (i = 1; i <= y; i++)
- {
- s = s*x;
- }
- return (s);
- }
- double modulus_(double x)
- {
- double res;
- res = fabs(x);
- return (res);
- }
- void menu()
- {
- cout << "=======PROGRAM FOR SCIENTIFIC CALCULATOR=======" << endl;
- cout << "enter the variabes" << endl;
- cout << "eneter a:" ;
- cout << "enter b: " ;
- cin>>a;
- cin >> b;
- cout << "enter the function which you want to perform" << endl;
- cout << "1.mult" << endl << "2.add" << endl << "3.sub" << endl << "4.div" << endl << "5.pow" << endl << "6.modulus" << endl;
- cout << "7.cos(0,30,60,90,45,37,53)" << endl << "8.sin(0,30,45,60,90,37,53)" << endl;
- }
- double cores(double ang)
- {
- double result = 0;
- if (ang == 45)
- {
- a = b = 1;
- c = a*a + b*b;
- cout << "the cos value of 45 deg is" << endl;
- result = (b / sqrt(c));
- }
- else if (ang == 60)
- {
- b = 1, c = 2;
- c = 2 * b;
- a = ((c*c) - (b*b));
- cout << "the cos value is" << result;
- }
- else if (ang == 30)
- {
- b = 1, c = 2;
- c = 2 * b;
- a = ((c*c) - (b*b));
- result = (sqrt(a) / c);
- }
- else if (ang == 90)
- {
- result = 1;
- cout << "cos value is ";
- }
- else if (ang == 37)
- {
- a = 3, b = 4;
- c = ((a*a) + (b*b));
- result = b / sqrt(c);
- cout << "the cos value of 37 is ";
- }
- else if (ang == 53)
- {
- a = 4, b = 3;
- c = ((a*a) + (b*b));
- result = a / sqrt(c);
- cout << "the cos value of 53 is ";
- }
- else if (ang == 0)
- {
- result == 1;
- cout << "the cos value is";
- }
- else
- {
- cout << "sorry out of the given credentials";
- }
- //getch();
- return (result);
- }
- double res(double ang)
- {
- double result = 0;
- if (ang == 45)
- {
- a = b = 1;
- c = a*a + b*b;
- cout << "the cos value of 45 deg is" << endl;
- result = (b / sqrt(c));
- cout << result;
- }
- else if (ang == 60)
- {
- b = 1, c = 2;
- c = 2 * b;
- a = ((c*c) - (b*b));
- result = (sqrt(a) / c);
- cout << "\n" << "the sin value is" << result;
- }
- else if (ang == 30)
- {
- b = 1, c = 2;
- c = 2 * b;
- a = ((c*c) - (b*b));
- result = (b / c);
- cout << "\n" << "the sin value is" << result;
- }
- else if (ang == 90)
- {
- result = 0;
- cout << "\n" << "the value of sin wll be" << result;
- }
- else if (ang == 37)
- {
- a = 3, b = 4;
- c = ((a*a) + (b*b));
- result = a / sqrt(c);
- cout << "\n" << "the sin value of 37 is" << result;
- }
- else if (ang == 53)
- {
- a = 4, b = 3;
- c = ((a*a) + (b*b));
- result = b / sqrt(c);
- cout << "\n" << "the sin value of 53 is" << result;
- }
- else if (ang == 0)
- {
- result == 0;
- cout << "\n" << "the sin value is " << result;
- }
- else
- {
- cout << "sorry out of the given credentials";
- }
- //getch();
- return (result);
- }
Advertisement
Add Comment
Please, Sign In to add comment