Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- //number line program
- int a, b, i;
- char c;
- scanf("%d %d\n", &a, &b); //a is the number and b is the number to be added or subtracted
- for(i=1; i<=3; i++) {
- scanf("%c", &c);
- if(c=='L') {
- a=a-b;
- }
- else if(c=='R') {
- a=a+b;
- }
- }
- printf("%d", a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement