Explanation of the program
This program finds the numbers which are divisible by 7 between 100 and 200. Initially the variable i is set to 100. The while loop uses each value of i to check whether it is divisible by 7 by using the "%" operator, if so the count is incremented and the value of i is printed. At each iteration in the while loop, the value of i is incremented, and this process continues till the value of i is less than 200.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int d,i=100,count=0,val;
clrscr();
printf("The numbers which are divisible by 7\nbetween 100 and 200: \n");
while(i<200)
{
if(i%7==0)
{
printf("\n");
count=count+1;
val=i;
printf("%d",val);
}
i=i+1;
}
printf("\n");
printf("count=%d",count);
getch();
}
Output
| Numbers divisible by 7 between 100 and 200 |
No comments:
Post a Comment