Program to print table of Given NO. and calculate sums of even & odd no. separately

#include<stdio.h>
#include<conio.h>
void main()
{
int i,num,res,esum=0,odsum=0;
clrscr();
   printf("\nEnter No");
   scanf("%d",&num);
   for(i=1;i<=10;i++)
   {
     res=num*i;
     printf("\n%d",res);
      if(res%2==0)
  esum=esum+res;
      else
  odsum=odsum+res;
   }
printf("\nEven Sum=%d",esum);
printf("\nOdd Sum=%d",odsum);
getch();
}

Leave a Reply