Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 06.no
- #include <stdio.h>
- void fact(int n);
- void prime(int n);
- void even(int n);
- int main()
- {
- int n,choice;
- scanf("%d",&n);
- scanf("%d",&choice);
- switch(choice)
- {
- case 1:
- {
- fact(n);
- break;
- }
- case 2:
- {
- prime(n);
- break;
- }
- case 3:
- {
- even(n);
- break;
- }
- default:
- printf("nothing");}
- }
- void fact(int n)
- {
- int fact=1;
- for(int i=1;i<=n;i++)
- fact=fact*i;
- printf("Factorial is=%d\n",fact);
- }
- void prime(int n)
- {
- int c=0;
- for(int i=2;i<n;i++)
- {
- if(n%i==0)
- c++;
- }
- if(c==0)
- printf("Prime\n");
- else
- printf("not prime\n");
- }
- void even(int n)
- {
- if(n%2==0)
- printf("Even\n");
- else
- printf("Odd\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement