#include<stdio.h>
#include<conio.h>
void main()
{
int choice;
int i,num,fact=1;
clrscr();
while(1)
{
printf("\n1. Factorial\n");
printf("\n2. Prime\n");
printf("\n3 Odd/Even\n");
printf("\n4. Exit");
printf("\n\nEnter Your Choice :");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Enter Any number To find Factorial : ");
scanf("%d",&num);
for(i=num-1;i>=1;i--)
num=num*i;
printf("\nFactorial is : %d",num);
break;
case 2:
printf("\nEnter Any Number To Find Prime Number :");
scanf("%d",&num);
for(i=2;i<num;i++)
{
if(num%i==0)
{
printf("\nNumber is not Prime");
break;
}
else
printf("\nNumber Is PRIME");
break;
}
break;
case 3:
printf("\nEnter ANy number to Find ODD/EVEN : ");
scanf("%d",num);
if(num%2==0)
printf("\nNumber is EVEN\n");
else
printf("\nNumber is ODD\n");
break;
case 4:
exit();
}
}
getch();
}
#include<conio.h>
void main()
{
int choice;
int i,num,fact=1;
clrscr();
while(1)
{
printf("\n1. Factorial\n");
printf("\n2. Prime\n");
printf("\n3 Odd/Even\n");
printf("\n4. Exit");
printf("\n\nEnter Your Choice :");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Enter Any number To find Factorial : ");
scanf("%d",&num);
for(i=num-1;i>=1;i--)
num=num*i;
printf("\nFactorial is : %d",num);
break;
case 2:
printf("\nEnter Any Number To Find Prime Number :");
scanf("%d",&num);
for(i=2;i<num;i++)
{
if(num%i==0)
{
printf("\nNumber is not Prime");
break;
}
else
printf("\nNumber Is PRIME");
break;
}
break;
case 3:
printf("\nEnter ANy number to Find ODD/EVEN : ");
scanf("%d",num);
if(num%2==0)
printf("\nNumber is EVEN\n");
else
printf("\nNumber is ODD\n");
break;
case 4:
exit();
}
}
getch();
}
No comments:
Post a Comment