Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     //number line program
  6.     int a, b, i;
  7.     char c;
  8.     scanf("%d %d\n", &a, &b); //a is the number and b is the number to be added or subtracted
  9.     for(i=1; i<=3; i++) {
  10.         scanf("%c", &c);
  11.         if(c=='L') {
  12.             a=a-b;
  13.         }
  14.         else if(c=='R') {
  15.             a=a+b;
  16.         }
  17.     }
  18.     printf("%d", a);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement