Need help

What is the problem with this program , when I enter 3 for trigonometric it show 1 for sin .....and does not recieve input

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
  #include<iostream>
#include<stdlib.h>
#include<conio.h>
#include<math.h>
#include<windows.h>
using namespace std;
int main()
{
	SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE|                           
                                                           FOREGROUND_GREEN|
                                                      FOREGROUND_INTENSITY|
                                                            BACKGROUND_RED );
	string str;
	int a,b,c,d,u,l,m,o;
	double f,v,n;
	float h;
	char e[30];
	do 
	{
	cout<<"Calculator Beta version: 0.9.9.8 \nSelect calculator types: \n1 FOR ARITHEMATICS: \n2 FOR SCIENTIFIC:\n3 FOR TRIGONOMETRIC\n ";
	cin>>u;
 if(u==1)
	 {
	 		cout<<"Enter 1 for addition  \n Enter 2 for subtraction \n Enter 3 for multiplication \n Enter 4 for division \n ";
	cin>>a;
          if(a==1)
	{
		cout<<"Enter two number to add  ";
		cin>>b>>c;
		d=b+c;
		cout<<"sum of "<<b<< " and "<<c<<" is "<<d<<"\n";
	getch();}
		else if(a==2){
			cout<<"Enter two number to subtract  ";
		cin>>b>>c;
		d=b-c;
		cout<<"subtraction of "<<b<< " from "<<c<<" is "<<d<<"\n";
	getch();}
		else if(a==3)
		{
			cout<<"Enter two number to multiply  ";
		cin>>b>>c;
		d=b*c;
		cout<<"multiplication of "<<b<< " and "<<c<<" is "<<d<<"\n";
getch();}
		else if(a==4)
		{
				cout<<"Enter two number to add  ";
		cin>>b>>c;
		d=b/c;
		cout<<"division of "<<b<< "/"<<c<<" is "<<d<<"\n";
		getch();
	} 
		else{
		cout<<"You enter wrong number";
	}
	 }
 else if(u==2)
	 {
	 	cout<<"Enter 1 to find log:\nEnter 2 to find percentage: \n3 For power: \n4 for square root ";
	cin>>a;
        if(a==1)
	{
		cout<<"Enter number to find log:   ";
		cin>>b;
	f=log10(b);
		cout<<"log of "<<b<<" is "<<f<<" \a \n";
		getch();}
		
		else if(a==2)
		{
				cout<<"Enter number to find percentage : \n  ";
		cin>>v;
		cout<<"Enter total number \n";
		cin>>n;
	f=(v*100)/n;
		cout<<"percentage of "<<v<< " from "<<n<< " is "<<f<<" \a \n";
		getch();
	}

	else if(a==3)
		{
				cout<<"Enter Base: \n ";
		cin>>h;
	    cout<<"Enter exponent: ";
	    cin>>a;
	    
		cout<<h<<" power "<<a<< " is equal to \a \n "<<pow(h,a);
		getch();
	}
		else if(a==4)
		{
				cout<<"Enter number to find square root:  ";
		cin>>f;
	
		cout<<"square root of "<<f<< " is "<<sqrt(f);
		getch();
	}
		else{
		cout<<"You enter wrong number";
	}
}
else if(u==3)
 {
 	cout<<"Enter 1 to find sin\nEnter 2 for cos\nEnter 3 for tan\n";
 	  if(a==1)
	{
		cout<<"Enter number to find sin:   ";
		cin>>l;
		m=sin(l);
		cout<<"sin of "<<l<<" is "<<m<<" \a \n";
		getch();
		}
	
		else if(a==2)
		{
				cout<<"Enter number to find cos : \n  ";
		cin>>v;
		b=sin(v);
		cout<<"cos of "<<v<< " is "<<b<<" \a \n";
		getch();
	}

	else if(a==3)
		{
				cout<<"Enter number to find tan:  ";
		cin>>h;
		v=tan(h);
		cout<<"tan of "<<h<<" is "<<v;
		getch();
	}
	else
	{
		cout<<"You enter wrong number: ";
	}
      }

SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE|                           
                                                           FOREGROUND_GREEN|
                                                      FOREGROUND_INTENSITY|
                                                            BACKGROUND_RED );
cout << "\n Enter any character to continue and Enter exit to exit: ";
    cin>>str;

system("cls");	}
   while(str != "exit");
  
}
I'm on old blackberry the code doesn't look properly but, it's just my phone or in option 3 you're missing cin>>a; ?
And you might want to try switch
Last edited on
Topic archived. No new replies allowed.