-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calculator #306
base: main
Are you sure you want to change the base?
Calculator #306
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In generale, prima di fare un commit, quindi un push, assicurati che il codice compili e che funzioni.
Il codice non produce un risultato "visivo": quando vengono digitati i tasti richiesti dal programma, esso termina con l'inserimento del secondo numero senza mostrarmi il risultato dell'operazione richiesta.
int main(){ | ||
cout<<"-------------Welcome to calculator---------------------"<<endl; | ||
cout<<"Chose your operation \n Press 1 to Sum \n Press 2 to Difference \n Press 3 to | ||
Multiplicate \n Press 4 to Division"<<endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In questa riga hai inserito un 'a capo' e quindi il compilatore si lamenta perchè non trova il "fine istruzione". Se vuoi scrivere codice multiriga, quindi rimanendo nella stessa istruzione (in questo caso cout
devi inserire un \
a fine riga per indicare al compilatore "Il codice prosegue sotto, quindi non è un errore"
Esempio: (nota il \
alla fine della riga)
cout << "Chose your operation \n Press 1 to Sum \n Press 2 to Difference \n Press 3 to \
Multiplicate \n Press 4 to Division "<<endl;
cout<<"Insert second number"<<endl; | ||
cin >> b; | ||
|
||
if(x==1)return Sum(a,b); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potresti usare uno switch case per migliorare la leggibilità del codice.
No description provided.