Showing posts with label Number. Show all posts
Showing posts with label Number. Show all posts

Monday, August 1, 2016

PROGRAM FOR PRIME NO- C Program

/*PROGRAM FOR PRIME NO.*/


#include<stdio.h>
#include<conio.h>
void main()
{
int i,flag=0,n;
clrscr();
printf("Enter the no.::");
scanf("%d",&n);
for (i=2;i<=n/2;i++)
{
if(n%i==0)
{
printf("Not prime");
}
flag==1;
break;
}
if(flag==0)
{
printf("Prime");
}
getch();
}


/* OUTPUT
Enter the no.::17
Prime*/

FACTORIAL OF A NUMBER- C Program

/* FACTORIAL OF A NUMBER*/


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j=1,fact=1;
clrscr();
printf("\n Enter the no.::");
scanf("%d",&i);
while(j<=i)
{
fact=fact*j;
j++;
}
printf("The Factorial of the number is %d",fact);
getch();
}


/*OUTPUT
Enter the no.::5

The Factorial of the number is 120*/

FACTORIAL OF A NUMBER- C Program

/* FACTORIAL OF A NUMBER*/


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j=1,fact=1;
clrscr();
printf("\n Enter the no.::");
scanf("%d",&i);
while(j<=i)
{
fact=fact*j;
j++;
}
printf("The Factorial of the number is %d",fact);
getch();
}


/*OUTPUT
Enter the no.::5

The Factorial of the number is 120*/