0

can someone help me with this?
"PROGRAM TO DISPLAY FACTORS OF A NUMBER"
Use A1,A2,A3..as variable.
Sample output
Enter apositive integer: 60
Factors of 60 are: 1 2 3 4 5 6 12 15 20 30 60
my teacher say, that we should use stdio.h kg conio.h

5
Contributors
4
Replies
28
Views
2 Years
Discussion Span
Last Post by New Jack
0

And did you use stdio.h to show us the result you already have? Perhaps totally wrong but that won't bother us to try to solve your problem.

0

Um 1, 4, 6, 12, 15, 20, 30 and 60 are not prime factors. the prime factors of 60 are 2, 2, 3, 5. You can prove that since 2*2 = 4 and 4 * 3 = 12 and 12 * 5 = 60

Votes + Comments
But it seems that you didn't look at the problem clearly.
0

My teacher say, that we should use stdio.h kg conio.h

stdio.h is commonly used for io (input/output) for programs in C, so you would be better to post this question in the DANIWEB C forum

Do NOT use conio.h if you want to code using standard C and thus to have portable code.

Can someone help me with this? "PROGRAM TO DISPLAY FACTORS OF A NUMBER"

Yes ... but firstly you need to make your own best attempt to code a solution and then to show us that code so we can see where you are at.

Use A1,A2,A3..as variables

NOT actually a good idea ... a better choice is to use variable names that describe what is being done.

Enter a positive integer: 60

int numIn;
printf( "Enter a number to find its factors: " );
scanf( "%d", &numIn );

/* now find & output all possible factors of numIn */

Factors of 60 are: 1 2 3 4 5 6 12 15 20 30 60

-1
#include<stdio.h>
int main()
{
    int i,input_number;
    scanf("%d",&input_number);
    for(i=1;i<=input_number;i++)
    {
        if(input_number%i==0)
            printf("%d ",i);
    }
    return 0;
}
Is that OK with you? 
Votes + Comments
Don't just give code to people asking for it. We do not do peoples homework for them!
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.