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                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
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 an interactive program to generate the divisors of a
given integer.
 Question Submitted By :: Tulika Srivastava
I also faced this Question!!     Rank Answer Posted By  
 
  Re: write an interactive program to generate the divisors of a given integer.
Answer
# 1
#include <stdio.h>

void div(int n){
int i=2;
    while(n%i!=0 && i!=n){
         i++; 
    }
     printf("%d ",i);
	if(i!=n){
	  div(n/i);
	}

}

main(){
int i;
printf("Enter number:");scanf("%d",&i);
printf("1 ");
div(i);
}
 
Is This Answer Correct ?    5 Yes 2 No
Neo
 
  Re: write an interactive program to generate the divisors of a given integer.
Answer
# 2
void div(int n){
static int i=1;
    while(i<=n){
    if(!(n%i))printf(" %d",i);
         i++;
    }
}

main(){
int i;
clrscr();
printf("Enter number:");scanf("%d",&i);
div(i);
getch();
}
 
Is This Answer Correct ?    3 Yes 2 No
Tamil
 
 
 
  Re: write an interactive program to generate the divisors of a given integer.
Answer
# 3
#include<stdio.h>
int main()
{
 int n,i=1;
 printf("Value for n\n");
 scanf("%d\n",&n);
 while(i<=n)
 {
   if(n%i == 0)
   printf("%d\n",i);
  
   i++;
 }
}
 
Is This Answer Correct ?    2 Yes 0 No
Dally
 
  Re: write an interactive program to generate the divisors of a given integer.
Answer
# 4
same program as above, optimising it a little bit.

#include<stdio.h>
int main()
{
 int n,i=1;
 printf("Value for n\n");
 scanf("%d\n",&n);
 while(i <= n/2)
 {
   if(n%i == 0)
   printf("%d\n",i);
  
   i++;
 }
 printf("%d\n",n);
}
 
Is This Answer Correct ?    0 Yes 0 No
Pradeep
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
Implement a function that returns the 5th element from the end in a singly linked list of integers in one pass. Microsoft6
write the program for maximum of the following numbers? 122,198,290,71,143,325,98  4
How to write a code for random pick from 1-1000 numbers? The output should contain the 10 numbers from the range 1-1000 which should pick randomly, ie ,for each time we run the code we should get different outputs. NetApp12
wt is d full form of c Wipro1
what is call by value and call by reference  2
how to estimate the disk access time? e.g. the time between read one byte and another byte in the disk. Google3
Write a C program to print 1 2 3 ... 100 without using loops?  5
main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); } wat is the o/p and how?  7
When is an interface "good"?  1
Hai why 'c' is the middle language  2
how to find out the union of two character arrays?  1
Given an array of length N containing integers between 1 and N, determine if it contains any duplicates. SilverKey2
what are the compilation steps? ( i want inside the compiler )  1
what is the difference between arrays and linked list Tech-Mahindra15
what is the advantage of using SEMAPHORES to ORDINARY VARIABLES??? NSN1
Find Index of least significant bit set in an Integer. ex. int value is say 10001000 results should be 4.  1
what is meant by c  4
char ch="{'H','I',0};printf("%s",ch);what is output Accenture9
what is difference b/w extern & volatile variable?? Teleca2
How to implement call back functions ? HP2
 
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