Saturday 14 March 2015

Print the numbers that are divisible by a given no Using C

# include <stdio.h>
# include <conio.h>
void main()
{
int i, n, d ;
clrscr() ;
printf("Enter the limit : ") ;
scanf("%d", &n) ;
printf("\nEnter the number : ") ;
scanf("%d", &d) ;
printf("\nThe numbers divisible by %d are :\n\n", d) ;
for(i = 1 ; i <= n ; i++)
if(i % d == 0)
printf("%d\t", i) ;
getch() ;
}

RUN 1 :
~~~~~~~
Enter the limit : 15
Enter the number : 3
The numbers divisible by 3 are :
3 6 9 12 15

No comments:

Post a Comment