Thursday, February 17, 2011

Decision Making and Branching

Write a program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by 7.

#include <stdio.h>
void main()
{
unsigned int x,y=0;
clrscr();
for(x=100;x<=200;x++)
{
if(x%7==0)
y=y+x;
}
printf("%u\n",y);
getch();
}

No comments:

Post a Comment