Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

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 by Superman365 (560 points)
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.

1 Answer

0 votes
answered Nov 25, 2020 by Peter Minarik (84,720 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 Superman365 (560 points)
What is the program code? I am unable to get it.
commented Feb 2, 2021 by Monish Palella (100 points)
#include<stdio.h>
int main()
{
int a,i,b[100],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;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...