#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,n,sum=0;
printf(“Enter the
number of element in array\t”);
scanf(“%d”,&n);
printf(“Enter the %d
elements\t”,n);
for(i=0;i<n;++i)
{
scanf(“%d”,&a[i]);
if(i%2==0)
sum=sum+a[i];
}
printf(“Sum is
%d”,sum);
getch();
}
OUTPUT :
Enter the number of element in array 10
0
1
2
3
4
5
6
7
8
9
Sum is : 25
0 comments:
Post a Comment