Advertisement
Guest User

talha

a guest
Oct 14th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1. // 06.no
  2. #include <stdio.h>
  3. void fact(int n);
  4. void prime(int n);
  5. void even(int n);
  6. int main()
  7. {
  8.     int n,choice;
  9.     scanf("%d",&n);
  10.     scanf("%d",&choice);
  11.     switch(choice)
  12.     {
  13.         case 1:
  14.             {
  15.                 fact(n);
  16.                 break;
  17.             }
  18.         case 2:
  19.             {
  20.                 prime(n);
  21.                 break;
  22.             }
  23.         case 3:
  24.             {
  25.                 even(n);
  26.                 break;
  27.             }
  28.         default:
  29.             printf("nothing");}
  30. }
  31. void fact(int n)
  32. {
  33.     int fact=1;
  34.     for(int i=1;i<=n;i++)
  35.         fact=fact*i;
  36.     printf("Factorial is=%d\n",fact);
  37. }
  38. void prime(int n)
  39. {
  40.     int c=0;
  41.    for(int i=2;i<n;i++)
  42.    {
  43.        if(n%i==0)
  44.           c++;
  45.  
  46.    }
  47.    if(c==0)
  48.     printf("Prime\n");
  49.    else
  50.    printf("not prime\n");
  51. }
  52. void even(int n)
  53. {
  54.     if(n%2==0)
  55.         printf("Even\n");
  56.     else
  57.         printf("Odd\n");
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement