0

How can I keep sth on cmd forever on c++

#include <iostream> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <conio.h> #include <windows.h> using namespace std; int main() { system("color F0") ; int life=3,point=0; while(life!=0) { int number,random; srand ( time(NULL) ); random= rand()%5 + 1; cout << "Choose a number between 1 and 5: "; cin >> number; cout << "Random number: " << random << "\t\t\t\t\t\t\tPoint: "<< point; if (number == point) { cout << "\nCongratulations\n"; life++; point++; Sleep(250); system("CLS"); } else { life--; cout << "\nPlease Try Again" << endl; Sleep(250); system("CLS"); } if(life == 0) { cout << "Your Point: " << point; cout <<"\nGood Bye"; exit(0); } } } hi guys i'm recently learning c++ by myself so be gentle :) i cant figure how to keep point on the screen forever and how not to print "please try again" when life=0 can you guys help me thx

2nd Mar 2017, 8:34 PM
Furkan Kabak
Furkan Kabak - avatar
2 odpowiedzi
0
to stop writing put that 2nd if condition just after life--;
2nd Mar 2017, 9:09 PM
Dominik Stawiński
Dominik Stawiński - avatar
0
thanks it worked but what about keeping point on screen?
2nd Mar 2017, 9:16 PM
Furkan Kabak
Furkan Kabak - avatar