ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
Write a program to generate prime factors of a given integer?
 Question Submitted By :: Vasu
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Write a program to generate prime factors of a given integer?
Answer
# 1
int main()
{
	int n,num,i;
	printf("enter the num");
	scanf("%d",&num);
	n=num;
	printf("\n");
	for(i=2;i<=n/2;i++)
	{
		if(n%i==0)
		{
			prime(i);
		}
	}
}

void prime(int x)
{
	int i,f=0;
	for(i=2;i<=x/2;i++)
	{
		if(x%i==0)
		{
			f=1;
			break;
		}
	}
	if(f==0)
		printf(" %d",x);

}
 
Is This Answer Correct ?    5 Yes 7 No
Rajesh Kumar S
 
  Re: Write a program to generate prime factors of a given integer?
Answer
# 2
#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 ?    5 Yes 0 No
Sourav Das
 
 
 
  Re: Write a program to generate prime factors of a given integer?
Answer
# 3
#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 ?    2 Yes 0 No
Priyanka Chauhan
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
program to find middle element of linklist? Huawei1
Name the language in which the compiler of "c" in written? Bajaj1
What is structure packing ? HP1
pgm to reverse string using arrays i.e god is love becomes love is god) (assumption:only space is used for seperation of words) no addtional memory used.i.e no temporary arrays can used. Persistent4
int arr[] = {1,2,3,4} int *ptr=arr; *(arr+3) = *++ptr + *ptr++; Final contents of arr[] Hughes4
#include <stdio.h> #define sqr(x) (x*x) int main() { int x=2; printf("value of x=%d",sqr(x+1)); } What is the value of x? Oracle13
void main() { int s[4][2]={ {1234,56},{1212,33},{1434,80},{1312,78} }; int (*p)[2]; int i,j,*pint; for(i=0;i<=3;i++) { p=&s[i]; pint=p; printf("\n"); for(j=0;j<=1;j++) printf("%d",*(pint+j)); } } while running this program it shows a warning-suspicious pointer conversion ie pint=p; my que is why should we assign the value of p to pint again.why cant we use it directly as *(p+j)..but if i use like tat the o/p is garbage value..  1
write a own function to compare two strings with out using stringcomparition function? LG-Soft3
hello friends what do u mean by BUS ERROR i got this error while i am doing my program in DATA STRUCTURES Wipro2
we all know about the function overloading concept used in C++ and we all learnt abt that.... but that concept is already came in C in a very smaller propotion ... my question is IN WHICH CONCEPT THERE IS A USE OF FUNCTION OVERLOADING IS USED in C language????????????? Google2
program to find which character is occured more times in a string and how many times it has occured? for example in the sentence "i love india" the output should be i & 3.  3
write a program to find the sum of the array elements in c language?  8
what is difference between ++(*p) and (*p)++ Accenture15
Tell about strtok & strstr functions Motorola2
pgm in c to reverse string by word using array(god is love becomes love is god) (no additional array can used,space is only delimiter between words ) Persistent1
write a function for strtok()?? Verifone1
Write a C program to print 1 2 3 ... 100 without using loops?  5
write a C code to reverse a string using a recursive function, without swapping or using an extra memory. Motorola2
#include<stdio.h> main() { char *p1; char *p2; p1=(char *) malloc(25); p2=(char *) malloc(25); strcpy(p1,"Ramco"); strcpy(p2,"Systems"); strcat(p1,p2); printf("%s",p1); } Tell me the output? Ramco5
totally how much header files r in c language TCS4
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com