daily pastebin goal
23%
SHARE
TWEET

FUNCIONES CON ARREGLOS

Razk2108 Oct 19th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5. void poblarArreglo(int arr[],int n){
  6.     for(int i=0;i<n;i++){
  7.         arr[i]=rand()%(10-99+1)+10;
  8.     }
  9. }
  10. void mostrarArreglo(int arr[],int n){
  11.     for(int i=0;i<n;i++){
  12.         cout<<arr[i]<<endl;
  13.     }
  14. }
  15. float promedio(int arr[],int n){
  16.     int suma=0;
  17.     for(int i=0;i<n;i++){
  18.         suma+=arr[i];
  19.     }
  20.     return suma*1.0/n;
  21. }
  22. int main(){
  23.     srand(time(NULL));
  24.     int numeros[9];
  25.     poblarArreglo(numeros,9);
  26.     cout<<"Los numeros aleatorios son: "<<endl;
  27.     mostrarArreglo(numeros,9);
  28.     cout<<"El promedio es: "<<promedio(numeros,9);
  29.     return 0;
  30.    
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top