diff --git a/verifica_1/esercizio1.cpp b/verifica_1/esercizio1.cpp new file mode 100644 index 0000000..9f06e25 --- /dev/null +++ b/verifica_1/esercizio1.cpp @@ -0,0 +1,29 @@ +/* +AUTORE: Manuel Vichi 3^AIN +Esercizio 1 +*/ +#include +using namespace std; +int main(void) { + int valore; + bool accettato = false; + while (accettato == false) { + cout << "Inserisci un valore: "; + cin >> valore; + cout << endl; + if (valore > -11 && valore < 11) { + cout << "Valore accettato" << endl; + accettato = true; + } else { + if (valore < -20 || valore > 20) { + cout << "Valore accettato" << endl; + accettato = true; + } + else { + cout << "ERRORE! Valore non valido!" << endl; + accettato = false; + } + } + } + return 0; +} diff --git a/verifica_1/esercizio2.cpp b/verifica_1/esercizio2.cpp new file mode 100644 index 0000000..df5e9b3 --- /dev/null +++ b/verifica_1/esercizio2.cpp @@ -0,0 +1,17 @@ +/* +AUTORE: Manuel Vichi 3^AIN +Esercizio 2 +*/ +#include +using namespace std; +int main(void) { + int giorni = 0; + int cioccolato = 20; + do { + //cout << "Giorno: " << giorni << endl << "Cioccolato: " << cioccolato << endl; + cioccolato = cioccolato + 0.1 * cioccolato; + giorni++; + } while (cioccolato <= 1000); + cout << "I giorni necessari affinche' il consumo di cioccolato superi i 1000 g sono: " << giorni << endl; + return 0; +} diff --git a/verifica_1/esercizio3.cpp b/verifica_1/esercizio3.cpp new file mode 100644 index 0000000..08f5459 --- /dev/null +++ b/verifica_1/esercizio3.cpp @@ -0,0 +1,24 @@ +/* +AUTORE: Manuel Vichi + +*/ +#include +using namespace std; +int main(void) { + unsigned int numero, esponente, potenza = 0, moltiplicazione = 0; + cout << "Inserisci un numero: "; + cin >> numero; + cout << endl; + cout << "Inserisci un esponente per la potenza di 2: "; + cin >> esponente; + cout << endl; + // Moltiplicazione: Calcolo della potenza + for (int temp = 0; temp < esponente; temp++) { + potenza = potenza + esponente; + } + for (int temp = 0; temp < potenza; temp++) { + moltiplicazione = moltiplicazione + numero; + } + cout << "Risultato Moltiplicazione: " << moltiplicazione << endl; + return 0; +}