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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is meant by keywords in c?

863


Why c is called object oriented language?

839


How can I discover how many arguments a function was actually called with?

861


a=10;b= 5;c=3;d=3; if(a printf(%d %d %d %d a,b,c,d) else printf("%d %d %d %d a,b,c,d);

882


Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon

2010


What is the use of typedef in structure in c?

736


What are the 5 elements of structure?

838


write a program to create a sparse matrix using dynamic memory allocation.

4651


what are the advantages of a macro over a function?

907


How can I do graphics in c?

800


Explain how can you tell whether two strings are the same?

829


Write a program to identify if a given binary tree is balanced or not.

941


What is an auto variable in c?

991


What is the benefit of using #define to declare a constant?

867


What is a constant and types of constants in c?

860