Created
January 20, 2013 13:42
-
-
Save DouglasLivingstone/4578709 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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