write an interactive program to generate the divisors of a
given integer.

Answers were Sorted based on User's Feedback



write an interactive program to generate the divisors of a given integer...

Answer / neo

#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 ?    25 Yes 11 No

write an interactive program to generate the divisors of a given integer...

Answer / rakesh ranjan

#include<conio.h>
#include<stdio.h>
main()
{
int n,i;
printf("entre the number");
scanf("%d",&n);
for(i=2;i<n;i++)
{
if(n%i==0)
printf("%d\n",i);
}
getch();
}

Is This Answer Correct ?    15 Yes 2 No

write an interactive program to generate the divisors of a given integer...

Answer / dally

#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 ?    8 Yes 5 No

write an interactive program to generate the divisors of a given integer...

Answer / tamil

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 ?    11 Yes 9 No

write an interactive program to generate the divisors of a given integer...

Answer / guest

Optimised!! :-) some extra condition added to avoid printing repeated numbers.

#include<stdio.h>
void dev(int n,int i)
{
if(n <= i) return;
while(i <= n){
if((n % i) == 0){
if(n!=i) printf("%d ",i);
printf("%d ",n/i);
break;
}
i++;
}
dev(n/i,i+1);
return;
}
main()
{
int n;

printf("Enter number:");
scanf("%d",&n);

dev(n,2);
printf("\n");
return 0;
}

Is This Answer Correct ?    2 Yes 5 No

write an interactive program to generate the divisors of a given integer...

Answer / pradeep

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 ?    2 Yes 7 No

write an interactive program to generate the divisors of a given integer...

Answer / buya

111,111,111*111,111,111=12345678910987654321

Is This Answer Correct ?    2 Yes 8 No

Post New Answer

More C Interview Questions

Explain what does the function toupper() do?

0 Answers  


main() { char *p1="Name"; char *p2; p2=(char *)malloc(20); while(*p2++=*p1++); printf("%s\n",p2); }

4 Answers   CitiGroup,


Write a C Program to display the following menu: Menu 1. Display 2. Copy 3. Append 4. Exit Accept the choice (1-4) from the user, and perform the following tasks: Choice 1: Accept a file name from the user and display the file on screen Choice 2: Accept two file names, and copy first file to the second Choice 3: Accept two file names, and append second file to the first file Choice 4: Terminate the program

1 Answers   Accenture, Concor, DMU, Satyam, Syntel, Tora,


write the program to find multiplication of 2-D matrix??????????

1 Answers  


Compare interpreters and compilers.

0 Answers  






A program to write a number of letters and numbers, such as counting and display

0 Answers  


Which is best linux os?

0 Answers  


WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?

1 Answers   IBM,


what is uses of .net

0 Answers  


What does the file stdio.h contain?

0 Answers  


what is the output of the program and explain why?? #include<stdio.h> void main ( ) { int k=4,j=0: switch (k) { case 3; j=300; case 4: j=400: case 5: j=500; } printf (ā€œ%d\nā€,j); }

14 Answers   Oracle,


What is the sizeof () operator?

0 Answers  


Categories