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
How to delete a node from linked list w/o using collectons?
What is volatile variable in c?
What are comments and how do you insert it in a C program?
What are two dimensional arrays alternatively called as?
Why do we use main function?
What are categories used for in c?
What is function prototype?
What is #pragma statements?
What is || operator and how does it function in a program?
What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25
Is c language still used?
Explain can the sizeof operator be used to tell the size of an array passed to a function?
what is ur strangth & weekness
Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent
Can we change the value of constant variable in c?