Print the numbers that are divisible by a given no.
Program:
#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();
}
Output:
Enter the limit : 15
Enter the number : 3
The numbers divisible by 3 are :
3 6 9 12 15
-
UpdatedDec 30, 2019
-
Views46,588
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order