# How to make a program, of which when we type a number it will tell which number it can be divided...

+1 vote
asked Nov 25, 2020
How to make a program, of which when we type a number it will tell which number it can be divided by, without a remainder, Is it odd/even and how many digit it is?

Example:

If the number is 18:

It should say It is an even number, can be divided by 1, 2, 3, 6, 18 and is 2 digit.

answered Nov 25, 2020 by (58,020 points)
It's fairly easy. Give it a go.

You need to use the modulus (%) operator. If a % b == 0 it means that a divided by b has a remainder of 0.

Now all you need to do is check all the numbers lass than your input (18 in your example) and see if they have the modulus 0 or not.

Good luck. ;)
commented Nov 25, 2020 by (560 points)
What is the program code? I am unable to get it.
commented Feb 2, 2021 by (100 points)
#include<stdio.h>
int main()
{
int a,i,b,j=0;
printf("enter the number");
scanf("%d",&a);
for(i=0;i<=n;i++)
{
if(a%i==0)
{
b[j]=a;
j++;
}
}
printf("number %d can be divided with ",a);
for(j=0;b[j]!='\0';j++)
{
printf("%d",b[j]);
}
return o;
}