Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Autor: Joel Cesar Fernandez Segura
- Fecha: 28/08/2014
- Tema: Vectores y Arreglos
- */
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- void mostrarArray(float []);
- float sumarElementos(float []);
- float multiplicarElementos(float []);
- int main(void){
- float array[10];
- float suma,multiplicacion;
- system("color 0a");
- cout<<"\n\t\t [ VECTORES EN C++ ]\n\n";
- cout<<"\n[EJERCICIO #1]\n";
- cout<<"\nOPERACIONES CON ELEMENTOS DE UN ARREGLO\n\n";
- for(int i=0;i<10;i++){
- cout<<"INGRESE ELEMENTO ["<<i+1<<"]:";
- cin>>array[i];
- }
- cout<<"\n\nEL ARREGLO ES :\n";
- mostrarArray(array);
- cout<<endl<<endl<<endl;
- suma=sumarElementos(array);
- multiplicacion=multiplicarElementos(array);
- cout<<"LA SUMA DE ELEMENTOS ES: "<<suma;
- cout<<"\n\nLA MULTIPLICACION DE ELEMENTOS ES: "<<multiplicacion;
- cout<<endl<<endl<<endl;
- return 0;
- }
- float sumarElementos(float array[]){
- float suma=0;
- for(int i=0;i<10;i++){
- suma+=array[i] ;
- }
- return suma;
- }
- float multiplicarElementos(float array[]){
- float mult=1;
- for(int i=0;i<10;i++){
- mult*=array[i] ;
- }
- return mult;
- }
- void mostrarArray(float array[]){
- for(int i=0;i<10;i++){
- cout<<array[i]<<" ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement