This
is a Character based User Interface or CUI based simple computerized solution
to manage the system activities. This prototype code saves time and energy of
its user by automating certain tasks. This system is either file handling type
or ROM type, and stores activities in a coder-defined file or on ROM memory
temporarily.
C++
is a typed language, so no need of code explanation as everything will be
cleared by itself by reading the code. If you know C++, you know this code.
It’s that simple!
Note
to students, draw a class diagram and flow chart of system by reading the code
itself. The Code::Blocks IDE 20.03+MinGW and Cygwin tool are used to test the
code.
Note
that some systems are very simple and need enhancement but they are complete on
their own in other terms.
|
GuessingNumberGame.cpp |
|
|
#include
<bits/stdc++.h> #include <iostream> #include
<windows.h> using namespace std; int solve() { system("cls"); int random_num,guessing,tries=0; srand(time(0));//seed random number
generator random_num=rand()%100+1;//random number
between 1 & 100 inclusive
cout<<endl<<endl<<endl<<" SIMPLE C++
GAME"<<endl; cout<<" GUESSING NUMBER
GAME!\n\n\n"<<endl; do { cout<<"enter a guessing number
between 1 and 100 inclusive"<<endl; cin>>guessing; ++tries; if(guessing>random_num) {
cout<<"higher"<<endl; } else if(guessing<random_num) { cout<<"lesser"<<endl; } else { cout<<"cheer!!!you got
it!"<<endl; cout<<"you took total
of "<<tries<<" tries!"<<endl; } } while (guessing!=random_num); cout<<endl<<endl<<endl; cout<<" GAME OVER!
"<<endl<<endl<<endl; return 0; } int main() { solve(); return 0; } |
|
|
For more C/C++ codes related information click here. …till next post, bye-bye and take care. |
|
No comments:
Post a Comment