Answer to Question #17501 in C++ for Jeremy Spackman

Question #17501
I am reading an ebook, teaching myself all the languages i'm starting with c++, i don't understand these problems and the ebook isn't very detailed. I'm studying Classes, Structures, and Objects. Is it possible i can see an example program like this or be given a better reference 5. Ups and Downs 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. 6. Wrapping Ups and Downs Modify the program you wrote for Programming Challenge 5, 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
1
Expert's answer
2012-10-30T11:30:01-0400
5.
#include <string>
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <windows.h>
using namespace std;

void gotoxy(short x, short y) {
COORDpos = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}

int main ()
{
intcount = 25;
for(int i = 1; i< 26; i++){
gotoxy(30,i);
cout<<"DOWN";
gotoxy(40,count);
cout<<"UP";
count--;
Sleep(500);
}

gotoxy(30,27);
system("pause");
return0;

}

6.
#include <string>
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <windows.h>
using namespace std;

void gotoxy(short x, short y) {
COORDpos = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}

int main ()
{
intcount = 25;
do{
for(int i = 1; i< 26; i++){
gotoxy(30,i);
cout<<"DOWN";
gotoxy(40,count);
cout<<"UP";
count--;
Sleep(50);
}
count= 25;
system("cls");

}while(kbhit()==0);
system("pause");

return0;

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
31.10.12, 15:45

You're welcome. We are glad to be helpful.
If you really liked our service please press like-button beside answer field. Thank you!

Jeremy Spackman
30.10.12, 19:57

Excellent work, i love it. Keep up the good work, and thank you.

Leave a comment

Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS