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

How to delete a node from linked list w/o using collectons?

2820


What is volatile variable in c?

1151


What are comments and how do you insert it in a C program?

1299


What are two dimensional arrays alternatively called as?

1242


Why do we use main function?

1232


What are categories used for in c?

1151


What is function prototype?

1210


What is #pragma statements?

1153


What is || operator and how does it function in a program?

1158


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

2038


Is c language still used?

1043


Explain can the sizeof operator be used to tell the size of an array passed to a function?

1115


what is ur strangth & weekness

2521


Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent

2171


Can we change the value of constant variable in c?

1113