Write a program to generate prime factors of a given integer?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / neha
#include<stdio.h>
#include<conio.h>
int main()
{
int num,i=1,j,k;
printf("\n\tEnter the number:");
scanf("%d",&num);
while(i<=num)
{
k=0;
if(num%i==0)
{
j=1;
while(j<=i)
{
if(i%j==0)
k++;
}
j++;
if(k==2)
printf("\n\t%d is a Prime factor:"i);
}
i++;
}
return 0;
}
Is This Answer Correct ? | 3 Yes | 0 No |
How can I write functions that take a variable number of arguments?
what is the structure pointer?
how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions
Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer
What is the explanation for prototype function in c?
Why is c so powerful?
Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings
How can I find the day of the week given the date?
Should I learn c before c++?
#define MAX 3 main() { printf("MAX = %d ",MAX ); #undef MAX #ifdef MAX printf("Vector Institute”); #endif }
how can i print "hello"
what is pointer ?
10 Answers Kernex Micro Systems,