Write a C program to generate all the numbers of the limit between 1 and n is a value supplied by count.
Read n value
Initialize count 0
for i 1 to n
for j 1 to i
if i mod j is equal to 0
then increment count
then print count.
#include<stdio.h>
int main()
{
int i, j, n, count=0;
printf("Enter the limit:");
scanf("%d", &n);
printf("The limit numbers are:\n");
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
if(i%j==0)
{
count++;
}
}
printf("%d\n", count);
}
return 0;
}
Enter the limit:5
The limit numbers are:
1
3
5
8
10