Skip to content

Instantly share code, notes, and snippets.

@DouglasLivingstone
Created January 20, 2013 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DouglasLivingstone/4578709 to your computer and use it in GitHub Desktop.
Save DouglasLivingstone/4578709 to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int a,b ,c,fac,d,rem,g,j,rem_1,e;
char another;
printf("Which one would you like to choose");
printf("\n1. Factorial Of a number \n 2.Prime or not\n 3. Odd or even\n 4. Exit ");
scanf("%d %d %d %d",&a);
while (a==1)
{
clrscr();
printf("You have choose n to find the factorial of a number.\n Please enter the number of your choice ");
scanf("%d",&b);
fac=1;
c=1;
while(c<=b){
fac=fac*c;
c++;
printf("The factorial of %d = %d",b,fac);
}
}
}
while(a==2)
{
clrscr();
printf("You have choosen to find if the number is prime or not \n Please enter the number of your choice");
scanf("%d",d);
for(e=1; e<=d;e++)
{
rem=d%e;
if(rem==0)
printf("The number is not a prime number");
else
printf("The number is a prime number");
}
}
while(a==3)
{
clrscr();
printf("You have choosen to find if the number is odd or even \n Please enter the number of your choice ");
scanf("%d",&g);
j=2;
rem_1=(g%j);
if(rem_1==0)
printf("The number is an even number ");
else
printf("The number is an odd number");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment