Thread: player svvitching to guess

  1. #1
    Registered User
    Join Date
    Dec 2017
    Posts
    37

    player svvitching to guess

    Code:
    #include "stdafx.h"
    #include <iostream>
    #include <string>
    #include <ctime>
    #include <stdlib.h>
    using namespace std;
    int main()
    {
        cout << "Player 1 = Abel\n";
        cout << "Player 2 = Moore\n";
    
        srand(time(NULL));
    
        int random_number;
    
        {int random_number = 1 + (rand() % 100);
        cout << random_number << endl; }
    
        int currentPlayerturn;
    
        {currentPlayerturn "Player 1"; }
    
        system("pause");
        return 0;
    }
    hovv do i change players to guess the number and hovv do I make the players guess the number

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Quote Originally Posted by sonicflare9 View Post
    hovv do i change players to guess the number ...
    Use "cin" to read their input?

    Quote Originally Posted by sonicflare9 View Post
    ... and hovv do I make the players guess the number
    Threaten them? Or,
    use "cin" to read their input?

  3. #3
    Banned
    Join Date
    Aug 2017
    Posts
    861
    I'd put a your turn user (x) message first then a means to get their guess next then do the rest then print out their results then repeat using a different var for a different user.

    you have gone over loops and allowed yourself enough time to work with them to get at least a decent understanding of how they work, other then just know one when you see it?

    just a little nudge, not something that is necessarily needed to be used, but just an example of a loop and usages of vars so you won't have to keep writing out the same thing again and again. even though you will still end up doing that anyways if you end up writing the same vars over again and again.
    Code:
    //#include "stdafx.h"
    #include <iostream>
    #include <string>
    #include <ctime>
    #include <stdlib.h>
    using namespace std;
    int main()
    {
        char what = '\0';
        char a[5] = "Abel";
        char b[6] = "Moore";
        char yourturn[11] = " Your turn";
    
     
        srand(time(NULL));
        
        cout <<"What is your name?"<<"\n";
        cin >> a;
         cout << "Player 1 is "<< a << "\n";
        cout << "Player 2 is "<< b << "\n"; 
        
        
        
        int random_number = (rand() % 100 + 1);
        
        while ( what != 'q')
        {
            
            cout << a << yourturn << "\n";
            
            what = 'q';
         }
        return 0;
    }
    Last edited by userxbw; 12-11-2017 at 08:44 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help vvith rand and svvitching players
    By sonicflare9 in forum C++ Programming
    Replies: 7
    Last Post: 12-05-2017, 05:03 PM
  2. Replies: 17
    Last Post: 10-20-2011, 06:32 PM
  3. Replies: 7
    Last Post: 10-19-2011, 08:45 AM
  4. Is it a watch? Is it an MP3 player? Is it a video player?
    By twomers in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 08-15-2006, 10:54 PM
  5. wave player or mp3 player using C
    By lliero in forum C Programming
    Replies: 5
    Last Post: 02-27-2002, 11:33 AM

Tags for this Thread