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
Why main is not a keyword in c?
What is the difference between procedural and functional programming?
Is there any demerits of using pointer?
Write a program to swap two numbers without using a temporary variable?
Write a program to print numbers from 1 to 100 without using loop in c?
What is the general form of a C program?
Is it acceptable to declare/define a variable in a c header?
Is there a built-in function in C that can be used for sorting data?
I have seen function declarations that look like this
Explain pointer. What are function pointers in C?
Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays
What is scope of variable in c?
Why c language?
How do I round numbers?
What is difference between %d and %i in c?