Write a program to generate prime factors of a given integer?

Answer Posted / sourav das

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j,k,l,n;
clrscr();
printf("Enter The Number:");
scanf("%d",&n);
i=1;
while(i<=n)
{
if(n%i==0)
{
j=1;
k=0;
l=1;
while(l<=j)
{
if(j%l==0)
k++;
l++;
}
if(k==2)
{
printf("\n%d is the prime factor of %d",l-1,n);
}
}
i++;
}
getch();
}

Is This Answer Correct ?    26 Yes 24 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is use of bit field?

774


What is double pointer?

560


in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none

604


How do I round numbers?

601


What is the difference between declaring a variable and defining a variable?

724






a value that does not change during program execution a) variabe b) argument c) parameter d) none

696


Why is event driven programming or procedural programming, better within specific scenario?

1955


How can you avoid including a header more than once?

565


Explain the properties of union. What is the size of a union variable

718


What is "Hungarian Notation"?

637


When should I declare a function?

623


How do you print only part of a string?

615


What are logical errors and how does it differ from syntax errors?

661


Write the syntax and purpose of a switch statement in C.

629


What does the error message "DGROUP exceeds 64K" mean?

727