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

Answer Posted / priyanka chauhan

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
clrscr();
printf("Enter the no: ");
scanf("%d",&n);
for(j=2;j<=n;j++)
{
if(n%j==0)
{
for(i=2;i<=j-1;i++)
{
if(j%i==0)
break;
}
if(i==j)
printf("%d ",j);
}
}
getch();
}

Is This Answer Correct ?    23 Yes 18 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between call by value and call by reference in c?

621


What does & mean in scanf?

606


where are auto variables stored? What are the characteristics of an auto variable?

597


FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above

627


What are the storage classes in C?

629






Differentiate between null and void pointers.

635


the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset

644


Can we declare variable anywhere in c?

539


How does selection sort work in c?

629


What are the types of data structures in c?

606


Why can't I perform arithmetic on a void* pointer?

639


4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.

1731


If null and 0 are equivalent as null pointer constants, which should I use?

583


What is header file definition?

575


What is the significance of scope resolution operator?

865