Tuesday, August 13, 2013

Write a c program to calculate the sum of all numbers from 0 to 100 (Both exclusive) that are divisible by 4.


#include<stdio.h>
#include<conio.h>

void main()
 {
  int i=0,sum=0;
  clrscr();
  while(i<=100)
   {
    if(i%4==0)
     {
      sum=sum+i;
     }
    i++;
   }
  printf("sum of all numbers from 0-100 i.e. devisible by 4==>%d",sum);
                                         

  getch();
 }




/**************************  OUTPUT WINDOW  ************************/


sum of all numbers from 0-100 i.e. devisible by 4==>1300


No comments:

Post a Comment