Advertisement
Choeiphyu

c program Lottery game

Mar 30th, 2020
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.79 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<conio.h>
  4. int main() {
  5.     int age    = 0;
  6.     int smoney = 0;
  7.     int id     = 0;
  8.     int number = 0;
  9.     int money  = 0;
  10.     int num    = 0;
  11.     printf("**Welcome to our lottery game**\n\n");
  12.     printf("Enter your age: ");
  13.     scanf_s("%d", &age);
  14.     if (age > 17) {
  15.         printf("Show your money: \n");
  16.         scanf_s("%d", & smoney);
  17.         printf("This is your show money:%d\n", smoney);
  18.         while (age > 17) {
  19.             printf("Enter your id: \n");
  20.             scanf_s("%d", &id);
  21.             while (id == 111) {
  22.                 printf("Enter your money <must be more than 1000ks>: ");
  23.                 scanf_s("%d", & money);
  24.                 while(money>900) {
  25.                     printf("Enter your number:");
  26.                     scanf_s("%d", & number);
  27.                         if (number == 222) {
  28.                             printf("You win the lottery\n");
  29.                             smoney = (money * 10 + smoney)-money;
  30.                             printf("This is your money: %d\n", smoney);
  31.                             printf("If you want to play game press 1\n");
  32.                             printf("If you want to quit game press 2\n");
  33.                             scanf_s("%d", &num);
  34.                             if (num == 1) {
  35.                                 printf("You can play again\n");
  36.                             }
  37.                             else {
  38.                                 printf("Good bye!!");
  39.                                 exit(0);
  40.                             }
  41.  
  42.                         }
  43.                         else {
  44.                             printf("Try again!!!\n");
  45.                             smoney = smoney - money;
  46.                             printf("This is your remain money: %d\n", smoney);
  47.                             printf("If you want to play game press1\n");
  48.                             printf("If you want to quit the game press 2\n");
  49.                             scanf_s("%d", &num);
  50.                             if (num == 1) {
  51.                                 printf("You can play again\n");
  52.                             }
  53.                             else {
  54.                                 printf("Good bye!!");
  55.                                 exit(0);
  56.                             }
  57.  
  58.                             if (smoney < 1000) {
  59.                                 printf("Try more!!\n you have not enough money\n");
  60.                                 exit(0);
  61.                             }
  62.                         }
  63.                    
  64.                    
  65.                 }
  66.                
  67.             }
  68.         }
  69.     }
  70.     else {
  71.         printf("You cannot play game\n");
  72.     }
  73.     _getch();
  74.     return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement