C Program to find input number in an array and the number at even places - With Output

#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
Share on Google Plus

About Akash Manhas

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment