Professional Documents
Culture Documents
#include<stdio.h>
#include<conio.h>
main()
{
int n,fact=1;
clrscr();
printf("Enter the any number");
scanf("%d",&n);
while(n>0)
{
fact=fact*n;
n=n-1;
}
printf("The factorial is=%d\n",fact);
getch();
}
Output:
Enter the any number
5
The factorial is=120
getch();
}
Output:
Enter the any number
21
The febeonic sereis is=0 1 1 2 3 5 8 13 21
#include<stdio.h>
#include<conio.h>
main()
{
int n,i=2;
clrscr();
printf("Enter the any number");
scanf("%d",&n);
for(i=2;i<n;i++)
{
if(n%i==0)
{
printf("Not Prime");
break;
}
}
if(n==i)
printf("Prime Number");
getch();
}
Output:
Enter the any number
66
Not Prime
PATTERN MATCHING
Write a program to print this figure.
12345
1234
123
12
1
#include<stdio.h>
#include<conio.h>
main()
{
int i,j;
clrscr();
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf(" %d",j);
}
printf("\n");
}
getch();
}
Output:
12345
1234
123
12
1
#include<stdio.h>
#include<conio.h>
main()
{
int i,j;
clrscr();
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}
Output:
*****
****
***
**
*