Write a program to generate prime factors of a given integer?
Answer Posted / mohammad nasim
include<stdio.h>
main()
{
int n;
printf("Enter a positive integer: ");
scanf("%d",&n);
printf("\nThe prime factors are:\n");
while((n/2)!= 0 || (n/3)!=0)
{
if(n%2==0)
{
printf("\t2");
n=n/2;
}
else
{
if(n%3==0)
{
printf("\t3");
n = n/3;
}
else
{
printf("\t%d",n);
break;
}
}
}
}
| Is This Answer Correct ? | 1 Yes | 6 No |
Post New Answer View All Answers
What is assignment operator?
How are Structure passing and returning implemented by the complier?
What are types of structure?
I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.
How many types of operator or there in c?
You have given 2 array. You need to find whether they will
create the same BST or not.
For example:
Array1:10 5 20 15 30
Array2:10 20 15 30 5
Result: True
Array1:10 5 20 15 30
Array2:10 15 20 30 5
Result: False
One Approach is Pretty Clear by creating BST O(nlogn) then
checking two tree for identical O(N) overall O(nlogn) ..we
need there exist O(N) Time & O(1) Space also without extra
space .Algorithm ??
DevoCoder
guest
Posted 3 months ago #
#define true 1
#define false 0
int check(int a1[],int a2[],int n1,int n2)
{
int i;
//n1 size of array a1[] and n2 size of a2[]
if(n1!=n2) return false;
//n1 and n2 must be same
for(i=0;i
The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?
Why we not create function inside function.
What is the explanation for cyclic nature of data types in c?
Explain what is the difference between functions getch() and getche()?
What is bin sh c?
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
What are the ways to a null pointer can use in c programming language?
1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321
Write a program to implement queue.