Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int peso, flag = 0;
- float altezza, imc;
- do {
- cout<<"Inserisci il peso (kg)."<<endl;
- cin>>peso;
- if (peso == 0) {
- cout<<"Hai inserito un peso nullo. Uscita dal programma."<<endl;
- flag += 1;
- }
- if (flag != 1) {
- cout<<"Inserisci l'altezza (cm)."<<endl;
- cin>>altezza;
- altezza /= 100;
- altezza *= altezza;
- imc = peso/altezza;
- if (imc >= 25) {
- cout<<"Sovrappeso."<<endl;
- } else if (imc <= 18.5) {
- cout<<"Sottopeso."<<endl;
- } else {
- cout<<"Peso nella norma."<<endl;
- }
- cout<<"Il tuo Indice di Massa Corporeo risulta "<<imc<<"."<<endl;
- }
- } while (peso != 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement