Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Sunday, 5 June 2016

PROBLEM 15:
Write a C Program to print out all of the factors of a number from 1 to N.
For N = 9, output is 1, 3, 9

For N = 7, output is 1, 7

code:

#include<stdio.h>
main()
{
int i=1,num;
printf("Enter num:");
scanf("%d",&num);
printf("%d ",i);
do
{
    i++;
if(num%i==0)
{
    printf("%d ",i);

}


}while(i!=num);
return 0;

}

Program Output:

For more problems click here

No comments:

Post a Comment