Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int addizione(int a, int b){
- return a+b;}
- int sottrazione(int a, int b){
- return a-b;}
- int moltiplicazione(int a, int b){
- return a*b;}
- float divisone(float a, float b){
- return a/b;}
- int main() {
- /*stampo il menu*/
- double a, b;
- int c;
- cin>>c;
- cout<<"inserisci due numeri: ";
- cin >> a;
- cin >> b;
- cout<<"Seleziona il numero corrispondente all'opzione desiderata: "<<endl;
- cout<<" \t menù "<<endl;
- cout<<" 1) addizione"<<endl;
- cout<<" 2) sottrazione"<<endl;
- cout<<" 3) moltiplicazione "<<endl;
- cout<<" 4) divisione"<<endl;
- cout<<" 0) esci "<<endl;
- /*inserisco il valore*/
- while(c<0 || c>4 ){
- cout<<"Hai inserito un valore non valido"<<endl;
- cout<<"reinserire un valore corretto (tra 0 e 4): ";
- cin>>a;
- }
- switch(c) {
- case 0:
- break;
- case 1:
- cout<< addizione(int a,int b); break;
- case 2:
- cout<< sottrazione (int a,int b); break;
- case 3:
- cout<< moltiplicazione(int a,int b);
- break;
- case 4:
- if(b==0) {
- cout<<"Alla prossima";
- exit(-1);
- }
- cout<< divisione (float a,float b);
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement