You are on page 1of 3

FACTORIAL OF A NUMBER

#include<stdio.h>

main()

int n,i,fact;

fact=1;

printf ("\n" " Enter a number");

scanf ("%d",&n);

for (i=1;i<=n;i++)

fact=fact*i;

printf ("\n" "the factorial is %d",fact);

}
Table of entered number

#include<stdio.h>

main()

int n,i;

printf ("\n" " Enter a number from 2 to 20");

scanf ("%d",&n);

for (i=1;i<=10;i++)

printf ("\n""%d", n*i);

}
To check d no is prime or not..

main() 

int a,c=0,i,n; 
printf("enter the number to be checked"); 
scanf("%d",&n); 
for(i=1;i<=n;i++) 
   { 
     a=n%i; 
     if(a=0) 
        { 
           c=c+1; 
        } 
    } 
if (c=2) 
  { printf("the given number is prime"); } 
else 
    printf("the given number is not prime"); 
}

You might also like