209k views
4 votes
Write a program that will accept input of two positive decimal integer values and output the prime factorizations of the input values. A sample run is below. User input is in boldface.

1 Answer

4 votes

Answer:

C code given below

Step-by-step explanation:

#include <stdio.h>

void factorize(int num){

int i = 2;

printf("The prime factorization of %d is ", num);

while(num != 0){

if(num % i == 0){

printf("%d", i);

num /= i;

if(num != 1){

printf("*");

}

else{

printf(".\\");

break;

}

}

else{

++i;

}

}

}

int main(){

int num;

printf("Give them to me one by one and I will do the factoring. \\");

printf("Number? ");

scanf("%d", &num);

factorize(num);

printf("Number? ");

scanf("%d", &num);

factorize(num);

return 0;

}

User Luiscri
by
5.2k points