please use any only four of the following statements. 1. if 2.if else 3.while 4.
ID: 3652918 • Letter: P
Question
please use any only four of the following statements. 1. if 2.if else 3.while 4. for as always use printf and scanf library function. (not the cin and cout thats for C++) A C program that will accept input of two positive decimal integer values amd output the prime factorizations of the input values. A sample run. so you want two numbers factored. Give them to me one by one and I will do the factoring. Number? 16 (user enter 16 in command prompt window) The prime factorization of 16 is 2 x 2 x 2 x 2 Number? 2080 (user enter 2080 in command prompt window) The prime factorization of 2080 is 2*2*2*2*2*5*13. You're welcome. The bill is in the mail.Explanation / Answer
please rate - thanks
if you don't use getch(); remove the 2 red lines of code
#include <stdio.h>
#include <conio.h>
int main()
{int num,i,j,first;
printf(" so you want two numbers factored. Give them to me one by one and I will do the factoring. ");
for(j=1;j<=2;j++)
{printf("Number? ");
scanf("%d",&num);
printf("The Prime factorization of %d is ",num);
i=2;
first=0;
while(i<=num )
{if(num%i==0)
{if(first==0)
{printf("%d ",i);
first=1;
}
else
printf("x %d ",i);
num=num/i;
}
else
i++;
}
printf(" ");
}
printf("You're welcome. The bill is in the mail. ");
getch();
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.