SUM OF EVEN TERMS
Code :
#include<stdio.h>
int main()
{
int num,n,i=1, sum = 0,count=1;
printf("========================================\n");
printf("\tSUM OF FIRST N EVEN TERMS\n");
printf("========================================\n");
printf("Enter maximum limit of even terms : ");
scanf("%d", &n);
while(count <= n)
{
if(i%2 == 0)
{
sum += i;
count++;
}
i++;
}
printf("\nSum of first %d even terms is, ", n);
printf("%d\n", sum);
printf("----------------------------------------\n");
return 0;
}
Come again Learn again !
« iCodeBuzz »
No comments:
Post a Comment