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

#include<stdio.h>
#include<conio.h>
void main()
{
   int	num,esum=0,odsum=0,i=1,res;
   clrscr();
   printf("\nENTER NUMBER=>");
   scanf("\n %d",&num);

   while(i<=10)
   {
    res=num*i;

    printf("\n %d",res);

      if(res%2==0)
      {
  esum=esum+res;
      }
      else
       {
    odsum=odsum+res;
  }
  i++;
   }
       printf("\n even sum==%d",esum);
      printf("\n odd number sum==%d",odsum);

getch();
}

Leave a Reply