Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

#include<stdio.

h>
/*Name: Aidan Gyle A. Abrogar
Section: BSIT1-YB-6
Activity Name: ACTIVITY 1 - One Dimensional Array
File Name: Activity1
*/
int main(){
int i, num, total = 0;
printf("Input number of elements: ");
scanf("%d", &num);
int element[num];
for (i = 0; i < num; i++){
printf("\nElement: ");
scanf("%d",&element[i]);
}
printf("\nThe %d elements are: ", num);
for(i = 0; i < num; i++){
printf("%d ", element[i]);
}
for ( i = 0; i < num; i++){
total = total += element[i];
}
printf("\n\nThe sum of %d elements is: %d\n", num,total);
printf("\nThe reverse of %d elements are: ", num);
for(i = num-1; i >=0; i--){
printf("%d ",element[i]);
} return 0;
}

You might also like