OCJP

Total Run of Players (Sum of Elements in Single Dimension Array)

Here is the program with Single Dimension Array to find out sum of the elements in Single Dimension Array.

#include<stdio.h>
#include<conio.h>
void main()
{
int run[7];
int i,sum=0;
clrscr();
printf("\n enetr runs of 7 players:");
for (i=0;i<7;i++)
{
printf("enetr run:");
scanf("%d",&run[i]);
sum=sum+run[i];
}
printf("\n total run is %d",sum);
for(i=0;i<7;i++)
{
printf("\n run [%d] is %d",i, run[i]);
}
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *


× How can I help you?