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.

Answers were Sorted based on User's Feedback



write an interactive program to generate the divisors of a given integer...

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

write an interactive program to generate the divisors of a given integer...

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

write an interactive program to generate the divisors of a given integer...

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

write an interactive program to generate the divisors of a given integer...

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

write an interactive program to generate the divisors of a given integer...

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

write an interactive program to generate the divisors of a given integer...

Answer / pradeep

same program as above, optimising it a little bit.

#include<stdio.h>
int main()
{
int n,i=1;
printf("Value for n\n");
scanf("%d\n",&n);
while(i <= n/2)
{
if(n%i == 0)
printf("%d\n",i);

i++;
}
printf("%d\n",n);
}

Is This Answer Correct ?    2 Yes 7 No

write an interactive program to generate the divisors of a given integer...

Answer / buya

111,111,111*111,111,111=12345678910987654321

Is This Answer Correct ?    2 Yes 8 No

Post New Answer

More C Interview Questions

Write a program in C for showing working of different logical operator in C. Your program should guide users with proper message/menu on the console.

3 Answers   HCL,


Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above

0 Answers  


Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.

0 Answers  


can we print any string in c language without using semicolon(;)(terminator) in whole program.

11 Answers  


who is the father of C Language?

20 Answers   CTS, UST,


What is return type in c?

0 Answers  


write a program for the normal snake games find in most of the mobiles.

0 Answers   Accenture, Wipro,


Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1

0 Answers  


what is the use of a array in c

6 Answers  


What is the output of printf("%d", printf("Hello"));?

1 Answers  


change to postfix a/(b+c*d-e)

8 Answers   Value Labs,


Why do we use return in c?

0 Answers  


Categories