C++ ROCK PAPER SCISSORS game for beginners 👊

แชร์
ฝัง

ความคิดเห็น • 37

  • @BroCodez
    @BroCodez  2 ปีที่แล้ว +6

    #include
    #include
    char getUserChoice();
    char getComputerChoice();
    void showChoice(char choice);
    void chooseWinner(char player, char computer);
    int main() {
    char player;
    char computer;
    player = getUserChoice();
    std::cout

  • @FrederikWollert
    @FrederikWollert 3 หลายเดือนก่อน +2

    I really like your C++ series. Keep it up. Please make more C++ Videos. So, let's defeat the TH-cam algorithm.

  • @sliky7317
    @sliky7317 2 ปีที่แล้ว

    I made this game before you made this video... but mine was so janky, It works though. I keep having issues with some things like while loops, and I think it's because I'm using an online compiler because I don't know any downloads for chromebook. Thanks for the free coding lessons man. Have a great day!

  • @criminalx7099
    @criminalx7099 2 ปีที่แล้ว

    well explained bro

  • @ahmadosama2652
    @ahmadosama2652 2 ปีที่แล้ว +11

    In chooseWinner function if we use if statement it will be more easier
    if(user == computer)
    std::cout

    • @realanderect6467
      @realanderect6467 ปีที่แล้ว +2

      did the same🤝

    • @ahmedghaly7161
      @ahmedghaly7161 หลายเดือนก่อน

      @@realanderect6467 can i ask where are you now at the programming guys ?

    • @alwinsanthosh6878
      @alwinsanthosh6878 20 วันที่ผ่านมา

      I'm only a beginner, but i feel like a dumbass for not recognizing this simpler form of code.

    • @realanderect6467
      @realanderect6467 8 วันที่ผ่านมา

      @@ahmedghaly7161 I am currently doing DSA in java... i liked java more than c++

  • @NoBeerNoLife1789
    @NoBeerNoLife1789 ปีที่แล้ว

    very thanks dude

  • @leomabuku1904
    @leomabuku1904 4 หลายเดือนก่อน

    This was weirdly silly but impressive
    Way of thinking implementation

  • @zabiullahsafdari-to8zw
    @zabiullahsafdari-to8zw 6 หลายเดือนก่อน

    Great

  • @hupmitom5509
    @hupmitom5509 ปีที่แล้ว

    the game is so funny, thank you.

  • @Sahan-od3vq
    @Sahan-od3vq 24 วันที่ผ่านมา

    bro why do you prefer defining functions rather than typing in whole like you did in python?
    is there any reason ??
    does defining functions reduces the compiling time??

  • @u___f
    @u___f ปีที่แล้ว +2

    Hi everyone, I added a do while loop in the main function to enable repeating the game and tried to display a counter each for the wins, ties and losses
    But the counters only worked when I copied the code from the chooseWinner function into the main function
    Does anyone have an idea how it would work with using the function?
    Thanks in any case

    • @u___f
      @u___f ปีที่แล้ว

      *it worked after using „int&“ in the function definition and declaration but not with „int“ only

    • @realanderect6467
      @realanderect6467 ปีที่แล้ว

      @@u___f yeah it is so because & means reference to a variable (address of a variable)... so if u just use int the value of the variable will go into the function and any change in u do in the function will not change the value of the variable... but if you use reference variable (&int), the address of the variable will go into the function and any change in u make in the function will change the value at that specific address.. thereby changing the value of the variable in the main function.

  • @Zyxmil
    @Zyxmil 6 หลายเดือนก่อน +1

    I don't know if anyone will see this, but I've tried making this program before seeing this video, what do you guys think on it
    #include
    #include
    char random(char comp);
    void final(char comp);
    int main()
    {
    std::cout answer;
    char finalanswer = toupper(answer);
    if (finalanswer == 'R' && comp == 'r')
    {
    std::cout

  • @ayaanshaikh2018
    @ayaanshaikh2018 29 วันที่ผ่านมา

    but why is the computer losing against me at every try??
    can we fix that ??

  • @user-tv1qi6vs1u
    @user-tv1qi6vs1u 5 หลายเดือนก่อน

    The name of the theme u use ?

  • @EliaPerzian-xy3co
    @EliaPerzian-xy3co 11 หลายเดือนก่อน

    Can someone please explain to me the void showchoice(char choice) why did we enter char choice and didnt use choice

    • @willixm2520
      @willixm2520 11 หลายเดือนก่อน

      when declaring the function, because we're passing in a variable through it, we have to also declare the datatype of the variable, which in this case is a char. Just like when creating a variable, we want to specify its datatype. Hope that helps and correct me if I'm wrong.

  • @albatablays24
    @albatablays24 ปีที่แล้ว

    you wrote void showChoice(char choice) where is the choice. You haven't declared a choice data in any of the function

    • @realanderect6467
      @realanderect6467 ปีที่แล้ว

      choice is a function variable which is declared in the function parameter list... when we called the function in the main function ( showChoice(player); ) that actually means that the value of choice in the function will be equal to player's value;

  • @lue224
    @lue224 2 ปีที่แล้ว +1

    why are you making so many functions you only need them once?

    • @ChrisVideosGreek
      @ChrisVideosGreek 2 ปีที่แล้ว

      to make it beginner-friendly

    • @lue224
      @lue224 2 ปีที่แล้ว

      @@ChrisVideosGreek yes but without it's simpler imo

    • @oximas-oe9vf
      @oximas-oe9vf ปีที่แล้ว +4

      @@lue224 it makes the program look cleaner and more understandable

    • @user-ci5kj5kq4c
      @user-ci5kj5kq4c 8 หลายเดือนก่อน

      to organise the code in a more readable way

  • @Azmnzmn
    @Azmnzmn 2 หลายเดือนก่อน +1

    My solution,
    #include
    #include
    int start() {
    std::cout > x;
    return x;
    }
    std::string raand() {
    srand(time(NULL));
    int a;
    a = 1 + rand() % 3;
    std::string str1;
    if (a == 1) { str1 = "ROCK"; }
    if (a == 2) { str1 = "PAPER"; }
    if (a == 3) { str1 = "SCISSOR"; }
    return str1;
    }
    int foo(int a) {
    int score(0);
    for (int i = 1; i

  • @user-wx8tc7bq5q
    @user-wx8tc7bq5q 7 หลายเดือนก่อน +1

    pls rate my code:
    #include
    #include
    using namespace std;
    int main()
    {
    bool run = true;
    while(run)
    {
    //all the variables
    std::string player;
    std::string computer;
    srand(time(NULL));
    int random = rand() % 3 + 1;
    std::string win;
    //variable for wanting to continue
    std::string want_continue;
    //main
    std::cout player;
    //code for the computer
    if(random == 1)
    {
    computer = "rock";
    std::cout

  • @thecrazytv6766
    @thecrazytv6766 3 หลายเดือนก่อน

    I did it a little bit different but it still works, don't mind the language it's serbian...
    #include
    #include
    char UnosKorisnika;
    void papir(char UnosKorisnika);
    void kamen(char UnosKorisnika);
    void makaze(char UnosKorisnika);
    int main()
    {
    srand(time(NULL));
    std::cout