473,378 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Can you fix this code?

#include "stdafx.h"

#include "cstdlib"

using namespace System;

int main(array<System::String ^^args)

{
int magic;

int guess ;

magic = rand();

magic=7;

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

guess=Console::Read();
if(guess == magic)

Console::WriteLine( L"Bravo");
else

Console::WriteLine(L"SORRY");
return 0;

}

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


May 8 '07 #1
3 1189
WELCOME ### wrote:
#include "stdafx.h"
It still sounds like you want a windows group!

--
Ian Collins.
May 8 '07 #2
"WELCOME ###" <fa***@alphalink.com.auwrote in message
news:46********@news.chariot.net.au...
#include "stdafx.h"

#include "cstdlib"

using namespace System;

int main(array<System::String ^^args)

{
int magic;

int guess ;

magic = rand();

magic=7;

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

guess=Console::Read();
if(guess == magic)

Console::WriteLine( L"Bravo");
else

Console::WriteLine(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;

}
May 8 '07 #3
On May 7, 10:19 pm, "WELCOME ###" <f...@alphalink.com.auwrote:
#include "stdafx.h"

#include "cstdlib"

using namespace System;

int main(array<System::String ^^args)

{

int magic;

int guess ;

magic = rand();

magic=7;

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

guess=Console::Read();

if(guess == magic)

Console::WriteLine( L"Bravo");

else

Console::WriteLine(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

May 8 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
109
by: Andrew Thompson | last post by:
It seems most people get there JS off web sites, which is entirely logical. But it is also a great pity since most of that code is of such poor quality. I was looking through the JS FAQ for any...
0
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to...
171
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
4
by: KenFehling | last post by:
Hello. I am wondering if there exists a piece of software that takes multiple .js files that are nicely indented and commented and create one big tightly packed .js file. I'm hoping the one file...
88
by: Peter Olcott | last post by:
Cab you write code directly in the Common Intermediate language? I need to optimize a critical real-time function.
7
by: blackrosezy | last post by:
#include char *code; void main() { char buf = "book";
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
1
by: ahammad | last post by:
Hello, I have written a fairly complex parsing tool that is used to parse information from company documents. The program works very well, but in order to insure that all the data is copied...
66
by: Jon Skeet [C# MVP] | last post by:
I'm sure the net will be buzzing with this news fairly soon, but just in case anyone hasn't seen it yet: Microsoft are going to make the source code for the .NET framework (parts of it,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.