0% found this document useful (0 votes)
50 views1 page

Trabajo 5

This C++ code defines functions to sum vectors and print them. It prompts the user to enter a number of elements, initializes three arrays to the elements, their sums, and sums of pairs. It calls the functions to sum the first elements into the third array, and print all three arrays, outputting the initial elements, their sums, and sums of pairs.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views1 page

Trabajo 5

This C++ code defines functions to sum vectors and print them. It prompts the user to enter a number of elements, initializes three arrays to the elements, their sums, and sums of pairs. It calls the functions to sum the first elements into the third array, and print all three arrays, outputting the initial elements, their sums, and sums of pairs.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

//VECTORES Y FUNCIONES

#include <iostream> using namespace std; void sumar(int a[], int b[], int c[],int dim) { for (int i = 0; i < dim; i++) { c[i] = a[i]*(a[i]+1)/2; } } void imprimir(int v[], int dim) { for(int i = 0; i < dim; i++) { cout << v[i] << endl; } cout << endl << endl; } int main() { int dim; cout << "INGRESE LA CANTIDAD N NUMEROS" << endl; cin >> dim; int a[dim]; int b[dim]; int c[dim]; for(int i = 0; i < dim; i++) { a[i] = i * 1; b[i] = i * (i + 1) ; } cout << "PRIMEROS N NUMEROS " << endl; imprimir(a, dim); sumar(a, b, c, dim); cout << "SUMA DE LOS PRIMEROS N NUMEROS " << endl; imprimir(c, dim); cout << "SUMA DE LOS PRIMEROS N NUMEROS PARES " << endl; imprimir(b, dim); system("pause"); return 0; }

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy