Related questions with answers
Write a program that displays the word UP on the bottom line of the screen a couple of inches to the left of center and displays the word DOWN on the top line of the screen a couple of inches to the right of center. Moving about once a second, move the word UP up a line and the word DOWN down a line until UP disappears at the top of the screen and DOWN disappears at the bottom of the screen.
Then, modify the program so that after disappearing off of the screen, the word UP reappears at the bottom of the screen and the word DOWN reappears at the top of the screen. The words should continue moving until the user presses the [Enter] key to terminate the program.
Solutions
VerifiedThis program exercise uses windows.h library to display an animation. Let’s start by importing it and defining a namespace
#include<iostream>
#include<windows.h>
using namespace std;
We add a new counter variables which is incremented each time the words goes out of range. When it reaches 3 the program terminates and the words disappear. See the code below.
#include <iostream>
#include <windows.h>
using namespace std;
void placeCursor(HANDLE screen, int row, int col)
{
COORD position;
position.Y = row;
position.X = col;
SetConsoleCursorPosition(screen, position);
}
Create a free account to view solutions
Create a free account to view solutions
Recommended textbook solutions

Computer Organization and Design MIPS Edition: The Hardware/Software Interface
5th Edition•ISBN: 9780124077263David A. Patterson, John L. Hennessy
Starting Out with C++: Early Objects
8th Edition•ISBN: 9780133360929Godfrey Muganda, Judy Walters, Tony Gaddis
Fundamentals of Database Systems
7th Edition•ISBN: 9780133970777Ramez Elmasri, Shamkant B. Navathe
Introduction to Algorithms
3rd Edition•ISBN: 9780262033848 (3 more)Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. CormenMore related questions
- computer science
1/4
- computer science
1/7