Halp not working

Whi it doesn't work

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
#include <iostream>

 using namespace std ;
   
   int main () 
   
   { // graffa int aperta
       
       int sum , num1 , num2 , diff , prod , quoz ;
       
       char si, segno , no , NO , SI ;
       
       char risp ;
       
       
       cout  << " CALCOLATRICE" << endl << endl << endl ;
       
       while(risp == si) ;
       
       { // graffa while aperta
       
       cout  << "INSERIRE L'OPERAZIONE DA EFFETTUARE IN QUESTA SEQUENZA : " << endl << endl ;
       
       cout  << " PRIMO NUMERO " << endl << endl ;
       
       cin >> num1 ;
       
       cout << " SEGNO DELL ' OPERAZIONE DA EFFETTUARE : ( * , / , + , - )." << endl << endl ;
       
       cin >> segno ;
       
       cout << " SECONDO NUMERO " << endl << endl ;  
       
       cin >> num2 ;
       
       
      switch(segno)
      
   {  // graffa switch aperta
   case '+' :
        
      sum = num1 + num2 ;
      
      cout << " La somma e' " << sum << endl << endl ;
      
      
      break;
      
   case '-' :
        
        diff = num1 - num2 ;
      
      cout << " La differenza e' " << diff << endl << endl ;
      
      
      break ;
        
   case '*' :
        
        prod = num1*num2 ;
      
      cout << "Il prodotto  e' " << prod << endl << endl ;
        
      
      break;
      
   case '/' :
        
      quoz = num1/num2 ;
      
      cout << " Il quoziente e' " << quoz << endl << endl ;
      
      
      
      
      break;
           
   default :
           
      cout << "SEGNO ERRATO ." << endl;
      
      
      
           } // graffa switch  chiusa
           
           
           
       
       
       cout << "Vuoi ricominciare ?? [ SI / NO ] " << endl ;
      
      cin >> risp ;
 
      } //graffa while chiusa
       
       system ("pause") ;
       
       return 0 ;
       
       } // graffa int chiusa
       
       
       
       
       
       
   
       
       
Is your program:
1) Not compiles
    * Is other code compiles correctly, i. e. is your compiler configured properly
    * If so, give us error message and corresponding code part.
2) Not running
    * Are you sure that it is not a problem with automatically closing console?
    * How do you run it?
    * Is there any error messages?
3) Gives an error when run
    * Is it system error message or error reported in console?
    * Give us error message and input which leads to error.
4) Not giving correct results
    * Tell what you entered, what you expected, and what you got.
    * Are you sure that results you expected are correct?
change these lines of code
1
2
3
4
5
6
char risp ;
       
       
       cout  << " CALCOLATRICE" << endl << endl << endl ;
       
       while(risp == si) ;
to
1
2
3
4
5
6
int risp = 1;
       
       
       cout  << " CALCOLATRICE" << endl << endl << endl ;
       
       while(risp == 1)

When you use a while statement you cant use a ; after a big no no also when using a logic check in a while statement you need to define before or it wont run and just changed it to a number to make easier
Also you should change your int for you sum, etc to a float otherwiese you wont get and decimal
Last edited on
Topic archived. No new replies allowed.