C program to enter array elements at the run time and then display on screen, also display sum of array elements
/*********************************************************
*C program to enter array elements at the run time and then display on screen.
* Also display sum of array elements
****************************************************************/
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
//array declaration
int number[5];
int sum=0;
//clrscr();
//Enter array elements
printf("Enter array elements\n");
for(i=0;i<5;i++)
{
//read array elements
scanf("%d",&number[i]);
}
//display array elements
printf("The array elements are\n");
for(i=0;i<5;i++)
{
printf("%d\t",number[i]);
//add array elements
sum=sum+number[i];
}
printf("\nThe sum of array elements is %d",sum);
printf("\nEnd of program");
}
Enter array elements
20
10
90
80
70
The array elements are
20 10 90 80 70
The sum of array elements is 270
End of program
0 टिप्पण्या
कृपया तुमच्या प्रियजनांना लेख शेअर करा आणि तुमचा अभिप्राय जरूर नोंदवा. 🙏 🙏