Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

how to make a game in c langague

+7 votes
asked Jan 8, 2021 by Ganesh (200 points)

1 Answer

0 votes
answered Jan 11, 2021 by Peter Minarik (86,180 points)
commented Jan 18, 2021 by Fidel Mendoza Jr (100 points)
Let me share this... but this is for C++

// "GUESSING A NUMBER" GAME
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;

int main ()
{
    string MyStr;
    int x = 0;
     
    cout<<"Guess a NUMBER from 1 to 10 \n";
    cout<<"The computer will tell you if that's the NUMBER\n";
     
    cout<<"Enter a number: ";
    getline (cin, MyStr);
    stringstream (MyStr)>>x;

    if (x==7){
        cout<< "You WIN - the number you entered "<<x<<" is the number  \n";
    }
    else cout<<"You loose - the number you entered "<<x<<" is not the number \n";
    return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...