View
10
Download
0
Category
Preview:
DESCRIPTION
ejercicio resuelto con arreglos
Citation preview
MATERIA:
FUNDAMENTOS DE
PROGRAMACIÓN
PROFESOR:
DORYS QUIROZ ING. SISTEMAS
ALUMNO:
CAPT DE COM. PAREDES R.POLO F.
ESPE-MATRIZ
Elaborar un programa que sume y escriba el contenido de los primeros n elementos de un
array ingresado desde teclado. El dato n debe ser leído desde teclado y ser menor a 300.
#include<stdio.h>
#include<conio.h>
#include<math.h>
const int tf=300;
int main()
{
int tl,i;
int arr[tf];
float acu=0;
do
{
printf("Ingrese el valor de n entre <1 y %d>: ",tf);
scanf("%d",&tl);
}
while(!(tl>0&&tl<=tf));
for(i=0;i<tl;i++)
{
printf("%d) Numero = ",i+1);
scanf("%d",arr+i);
acu+=arr[i];
}
printf("Los numeros ingresados son:\n");
for(i=0;i<tl;i++)
printf("%d) Numero = %d\n",i+1,arr[i]);
printf("La sumatoria es %.0f",acu);
getch();
}
Recommended