We provide Engineering,HSEB notes, tutorials which can be helpful for students during college life.
Friday, April 10, 2015
13. Write a C program to display the sum of 'n' terms of even numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int num[100],i,n,sum=0;
clrscr();
printf("\n How many numbers:-");
scanf("%d",&n);
printf("\n Input any %d numbers:- ",n);
for(i=0;i<n;i++)
{
printf("\n Number [%d]:- ",i);
scanf("%d",&num[i]);
if(num[i]%2!=0)
sum= sum+num[i];
}
printf("\n sum=%d",sum);
getch();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment