write an interactive program to generate the divisors of a
given integer.
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
#include<stdio.h> void main() { char *str; long unsigned int add; str="Hello C"; add=&str[0]; printf("%c",add); } What is the output?
Determine the code below, tell me exactly how many times is the operation sum++ performed ? for ( i = 0; i < 100; i++ ) for ( j = 100; j > 100 - i; j--) sum++;
What are global variables and explain how do you declare them?
plz answer.... write a program that reads line (using getline) e.g."345", converts each line to an integer using "atoi" and computes the average of all the numbers read. also compute the standard deviation.
how many keywords are available in 'c' language a) 32 b) 34 c) 45 d) 48
write a programme that inputs a number by user and gives its multiplication table.
What is the restrict keyword in C?
find the sum of two matrices and WAP for it.
Can we assign integer value to char in c?
what is the structure?
What is a structure in c language. how to initialise a structure in c?
What is C++