Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Explain how are 16- and 32-bit numbers stored?

1273


I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...

10206


What is binary tree in c?

1106


What is the use of static variable in c?

1092


What are the differences between new and malloc in C?

1150


If the size of int data type is two bytes, what is the range of signed int data type?

1026


What is difference between structure and union with example?

1060


What are the different types of control structures?

1048


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

1976


Explain the difference between strcpy() and memcpy() function?

1015


How can you avoid including a header more than once?

988


What are loops in c?

1011


Which is the best website to learn c programming?

1082


What do you mean by c what are the main characteristics of c language?

1037


Can you explain the four storage classes in C?

1125