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 are the 5 organizational structures?

803


Can a function argument have default value?

908


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

1021


An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above

909


what is a constant pointer in C

889


Why is c called "mother" language?

1060


write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

2222


int i=10; printf("%d %d %d", i, i=20, i);

1304


What is an array in c?

790


What is difference between union and structure in c?

785


Why static variable is used in c?

769


How can you find the exact size of a data type in c?

784


What is the difference between far and near ?

931


Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.

1772


What do you mean by dynamic memory allocation in c?

853