waltermilner

Untitled

Mar 14th, 2017
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. #include <stdio.h> // for output
  2.  
  3.  
  4. int main () // execution starts here
  5. {
  6.  
  7.    printf("Who will enter the number(or string) first? If Mr. X wants to enter first, press 1; if Y wants to enter first, press 2\n");
  8.    // this is a comment
  9.    // /n means new line
  10.    int reply;
  11.    int xNum, yNum;
  12.    scanf("%d", &reply);
  13.    // &reply means the address of reply
  14.    if (reply==1)
  15.    {
  16.    printf("Welcome Mr. X, Please enter a number\n");
  17.    scanf("%d", &xNum); // %d means format as decimal number
  18.    printf("Welcome Mr. Y, Please enter a number\n");
  19.    scanf("%d", &yNum);
  20.    }
  21.    else // in fact anything but 1
  22.    {
  23.    printf("Welcome Mr. Y, Please enter a number\n");
  24.    scanf("%d", &yNum);
  25.    printf("Welcome Mr. X, Please enter a number\n");
  26.    scanf("%d", &xNum);
  27.    }
  28.    printf("Mr. X entered %d and Mr Y %d\n",xNum,yNum);
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment