Have a Read!

Hi Everyone.
The idea for this page is to provide new c users simple c tutorials to learn how to develop the logic and more importantly correct way to write syntax.
ENJOY !!!

Thursday, January 27, 2011

C PROGRAM FOR FACTORS OF A NUMBER

#include <stdio.h>
int main()
{
int x,y,z;
printf("enter the number: ");
scanf("%d",&x);
printf("The factors are as follow:\n");
for (y=1;y<=x;y++)
      { if (x%y==0)
        printf("%d\n",y);}// loop end
return 0;
}

No comments:

Post a Comment

Related Posts with Thumbnails