#include(stdio.h>
#include(conio.h)
void main( )
{
int no,x;
clrscr( );
printf("Enter the required number:");
scanf("%d",&no);
printf("\nThe factors are:");
for(x=1; x<=no; x++)
{
if(no%x==0)
printf("\n%d",x);
}
getch( );
}
Output:-
Enter the required number: 27
The factors are:
1
3
9
27
Friday, May 22, 2009
Subscribe to:
Post Comments (Atom)
superb boss....thanx.its working......write for other programs..vil be helpful for beginners....
ReplyDeleteThanks alot!
ReplyDeletehi can u write factors of a program by using while loop
ReplyDeletemain()
Delete{
int c=1,n;
printf("Enter any number\n");
scanf("%d",&n);
while(c<=n/2)
{
if(n%c==0)printf("%d\t",c);
c++;
}
}
wow thats cool programing concept .really i will become a software developer.
ReplyDeletesuperrrrrrrrrrrrrrrrrbbbbbbbbbbbbbb bosssssssssssssssssss
ReplyDeletefor(x=1;x<=no/2;x++) this for loop also give the same output.
ReplyDeletethanx a lot. nice trying
ReplyDeletenice
ReplyDeletebut what abt negative numbers
wt is presentation error plz tel me any one
ReplyDeletethank you
ReplyDeleteNice................
ReplyDeleteBasic C Program for Computer Programmer who want to learn. If you have simple wish you may visit. To get all update stay with us.
Outline:
• Language: C and Simscript.
• if (Condition) statement and Nested if statement is used to determine the given number is positive, negative, even or odd. Another way we solve this program using if-else-if ladder.
• When the given condition or expression is true the statement associated with it executed.
To know details:
http://www.secufoon.com/write-a-c-program-for-determining-a-number-is-positive-negative-even-or-odd/
after the factor of no. then squaring and add the factor of the no.
ReplyDeletecan anyone send me the algorithm for c program to find factors of the give number ?
ReplyDeleteHow to find for negative nmrs
ReplyDelete