Advertisement
luishh

ex9-c++

Apr 2nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main () {
  5.     int id,soma=0,qtd=0,maior=0,menor=0;
  6.     do {
  7.         cout<<"INFORME A IDADE: "<<endl;
  8.         cin>>id;
  9.         if (id>0)
  10.         {
  11.             qtd++; //qtd-qtd+1
  12.             soma=soma+id; //soma +-id
  13.             if (id>maior)
  14.               maior=id;
  15.               if (menor==0)
  16.                  menor=id;
  17.             else
  18.               if (menor>id)
  19.                menor=id;
  20.         }
  21.                        
  22.     } while (id!=0);
  23.     if(qtd>0)
  24.     {
  25.      cout<<"MEDIA = "<<soma/qtd<<endl;
  26.      cout<<"MAIOR IDADE = "<<maior<<endl;
  27.      cout<<"MENOR IDADE = "<<menor<<endl;
  28.     }
  29.     else
  30.      cout<<"NÃO FORAM INFORMADAS IDADES VALIDAS"<<endl;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement