Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main () {
- int id,soma=0,qtd=0,maior=0,menor=0;
- do {
- cout<<"INFORME A IDADE: "<<endl;
- cin>>id;
- if (id>0)
- {
- qtd++; //qtd-qtd+1
- soma=soma+id; //soma +-id
- if (id>maior)
- maior=id;
- if (menor==0)
- menor=id;
- else
- if (menor>id)
- menor=id;
- }
- } while (id!=0);
- if(qtd>0)
- {
- cout<<"MEDIA = "<<soma/qtd<<endl;
- cout<<"MAIOR IDADE = "<<maior<<endl;
- cout<<"MENOR IDADE = "<<menor<<endl;
- }
- else
- cout<<"NÃO FORAM INFORMADAS IDADES VALIDAS"<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement