write an interactive program to generate the divisors of a
given integer.
Answer Posted / 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 |
Post New Answer View All Answers
Write a program for Overriding.
i have a written test for microland please give me test pattern
How to declare pointer variables?
What does sizeof int return?
Write a program to know whether the input number is an armstrong number.
Is anything faster than c?
Write a C program to help a HiFi’s Restaurant automate its breakfast billing system. Your assignment should implement the following items: a. Show the customer the different breakfast items offered by the HiFi’s Restaurant. b. Allow the customer to select more than one item from the menu. c. Calculate and print the bill to the customer. d. Produce a report to present your complete program and show more sample output. Assume that the HiFi’s Restaurant offers the following breakfast menu: Plain Egg $2.50 Bacon and Egg $3.45 Muffin $2.20 French Toast $2.95 Fruit Basket $3.45 Cereal $0.70 Coffee $1.50 Tea $1.80
How do you define a string?
What is the difference between char array and char pointer?
What is the purpose of scanf() and printf() functions?
How to write a code for implementing my own printf() and
scanf().... Please hep me in this... I need a guidance...
Can you give an coding for c... Please also explain about
the header files used other than #include
In c language can we compile a program without main() function?
Explain the term printf() and scanf() used in c language?
What are type modifiers in c?
Write a code of a general series where the next element is the sum of last k terms.