Write a program to generate prime factors of a given integer?
Answer Posted / ruchi
#include<stdio.h>
#include<conio.h>
int main()
{
int num,i,f=0,k=0,d,m;
printf("\n Enter the number ");
scanf("%d",&num);
m=num;
while(k<=m)
{
k=k+1;
f=0;
d=num%k;
if(d==0)
{
i=2;
while(i<=k-1)
{
if(k%i==0)
{
break;
}
i++;
}
if(i==k)
{
printf("\nPrime Factor %d ",k);
}
}
}
getch();
}
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
Explain the use of keyword 'register' with respect to variables.
What are c header files?
What is the basic structure of c?
How does placing some code lines between the comment symbol help in debugging the code?
How do you search data in a data file using random access method?
What is an endless loop?
What is const and volatile in c?
Explain what are the standard predefined macros?
Can you write the function prototype, definition and mention the other requirements.
Program will then find the largest of three numbers using nested if-else statements. User is prompted to enter three numbers. Program will find the largest number and display it on the screen. All three numbers entered by the user are also displayed. If user enters 21, 33, and 5, the output should be as follows: You entered: 21, 33 and 5. The largest number is 33.
How can I convert a number to a string?
What is selection sort in c?
Is Exception handling possible in c language?
What is file in c preprocessor?
What is a ternary operator in c?