Can you fix this code?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • WELCOME  ###

    Can you fix this code?

    #include "stdafx.h"

    #include "cstdlib"

    using namespace System;

    int main(array<Syst em::String ^^args)

    {


    int magic;

    int guess ;

    magic = rand();

    magic=7;

    Console::Write( L" Enter your Guess Number : ");

    guess=Console:: Read();


    if(guess == magic)

    Console::WriteL ine( L"Bravo");


    else

    Console::WriteL ine(L"SORRY");


    return 0;

    }

    +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++




  • Ian Collins

    #2
    Re: Can you fix this code?

    WELCOME ### wrote:
    #include "stdafx.h"
    >
    It still sounds like you want a windows group!

    --
    Ian Collins.

    Comment

    • Jim Langston

      #3
      Re: Can you fix this code?

      "WELCOME ###" <fares@alphalin k.com.auwrote in message
      news:463fde26_4 @news.chariot.n et.au...
      #include "stdafx.h"
      >
      #include "cstdlib"
      >
      using namespace System;
      >
      int main(array<Syst em::String ^^args)
      >
      {
      >
      >
      int magic;
      >
      int guess ;
      >
      magic = rand();
      >
      magic=7;
      >
      Console::Write( L" Enter your Guess Number : ");
      >
      guess=Console:: Read();
      >
      >
      if(guess == magic)
      >
      Console::WriteL ine( L"Bravo");
      >
      >
      else
      >
      Console::WriteL ine(L"SORRY");
      >
      >
      return 0;
      >
      }
      >
      +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++
      May have sytnax errors (not tested)

      #include <iostream>
      int main()
      {
      int magic;

      // magic = rand();

      magic=7;

      std::cout << "Enter your guess number: ";

      int guess ;
      if ( std::cin >guess )
      if (guess == magic)
      std::cout << "\nBravo\n" ;
      else
      std::cout << "\nSORRY\n" ;

      return 0;

      }


      Comment

      • pmouse

        #4
        Re: Can you fix this code?

        On May 7, 10:19 pm, "WELCOME ###" <f...@alphalink .com.auwrote:
        #include "stdafx.h"
        >
        #include "cstdlib"
        >
        using namespace System;
        >
        int main(array<Syst em::String ^^args)
        >
        {
        >
        int magic;
        >
        int guess ;
        >
        magic = rand();
        >
        magic=7;
        >
        Console::Write( L" Enter your Guess Number : ");
        >
        guess=Console:: Read();
        >
        if(guess == magic)
        >
        Console::WriteL ine( L"Bravo");
        >
        else
        >
        Console::WriteL ine(L"SORRY");
        >
        return 0;
        >
        }
        >
        +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++
        This looks like c++/cli to me. So instead of rand(), use Random^ r =
        gcnew Random(); and r->Next();

        and make sure your compiler supports CLI, and the options is turned
        on.

        Regards,

        PQ

        Comment

        Working...