Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Friday, February 11, 2011

C15 : Print numbers that is divisible by 7

Back to Home   &  C


//Program to print numbers that is completely divisible by 7 between 1 and n,
also count total number,and find its sum

#include<stdio.h>
#include<conio.h>
void main()
 {
 clrscr();
 int i=0,ct=0,sum=0,n;
 printf("Enter limit value\n");
 scanf("%d",&n);
 printf("The numbers are...\n");
 while(i<=n)
 {
 if(i%7==0)
 {
 printf("%d\n",i);
 ct++;
 sum=sum+i;
 }
 i++;
 }
 printf("sum=%d\n",sum);
 printf("count=%d",ct);
 getch();
 }
-----------------------------------------------------------------------------------
Output
Enter Limit
50
Numbers are...
0
7
14
21
28
35
42
49
sum=196
count=8
====================================
Back to Home   &  C


No comments: