Advertisement
esquilo10

Programa estrutura de repetição Ynoguti

Mar 22nd, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main (){
  6.     int n;
  7.     int soma=0;
  8.     int i;
  9.     int numero;
  10.     float media;
  11.     cout << "Quantos numeros" << endl;
  12.     cin >> n;
  13.     cout << "Digite " << n << " numeros" << endl;
  14.     i =0;
  15.     while (i<n){
  16.         cin >> numero;
  17.         soma = soma+numero;//IMPORTANTE
  18.         i ++;
  19.     }
  20.     cout << "Soma = " << soma << endl;
  21.     media = (float)soma/n;//ou multiplica por 1.0
  22.     cout << "Media = " << media << endl;
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement