Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main (){
- int n;
- int soma=0;
- int i;
- int numero;
- float media;
- cout << "Quantos numeros" << endl;
- cin >> n;
- cout << "Digite " << n << " numeros" << endl;
- i =0;
- while (i<n){
- cin >> numero;
- soma = soma+numero;//IMPORTANTE
- i ++;
- }
- cout << "Soma = " << soma << endl;
- media = (float)soma/n;//ou multiplica por 1.0
- cout << "Media = " << media << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement