Anvis

Arrangement+total/Avg in C++

Apr 18th, 2017
35
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. #include<conio.h>
  3. #include<math.h>
  4. #include<stdlib.h>
  5. using namespace std;
  6. int main(){
  7.     int menu, i, sum, arreglo[1], n;
  8.     float prom;
  9.     sum=0;
  10.     do{ system("cls");
  11.         cout << "Elige el tamaΓ±o del arreglo:";
  12.         cin >> n;
  13.         for (i=0; i<n; i++){
  14.             cout << "Introduzca el valor " <<i+1<<"\n";
  15.             cin >> arreglo[i];
  16.             sum=sum+arreglo[i];
  17.             }
  18.         prom=sum/n;
  19.         cout << "Suma: " <<sum<<endl;
  20.         cout << "Promedio: " <<prom<<endl;
  21.         cout << "Que deseas hacer? \n 1. Seguir en el programa\n 2. Salir del programa \n";
  22.         cin >> menu;
  23.     }
  24.     while(menu==1);
  25. }
Add Comment
Please, Sign In to add comment