>> Anyone can do this in C++
Yeah !
thekashyap
Practically a Posting Shark
811 posts since Feb 2007
Reputation Points: 254
Solved Threads: 75
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
maybe you show us what you have done and we can show you the right way... WE DON'T GIVE HOMEWORK TO THOSE WHO DON'T SHOW ANY EFFORT
we surely can do it... can you?
Nichito
Posting Virtuoso
1,602 posts since Mar 2007
Reputation Points: 424
Solved Threads: 57
i guess the title is missing a question mark in the end...
Nichito
Posting Virtuoso
1,602 posts since Mar 2007
Reputation Points: 424
Solved Threads: 57
I don't know C++ well enough to do this. ;)
If you don't know C++ well enough to even give it a try, you should just step back and learn the basics, give this problem a try and come back if you have some issues. Because there is no way someone is gonna teach you C++ language in one post here.
thekashyap
Practically a Posting Shark
811 posts since Feb 2007
Reputation Points: 254
Solved Threads: 75
First thing I'd do is calculate the random value first. This way you have the option of asking "Do you want to try another number?"
Next thing, rather than asking for each individual number (since you are only using 0-9) have the user enter a 5 digit value.
I'll let you work out the syntax for your program, but an array is just a variable that can contain multiple values. For example:
int ary[5]
defines the variableary to contain 5 values, ary[0] thru ary[4]. So in your code,
ary[0] would be a
ary[1] would be b
ary[2] would be c
ary[3] would be d
ary[4] would be e
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
this is my program..
See now we know what you don't know.. :)
See this link to learn teh abt arrays in C++. It tells you:
- What is an array?
- How create an array ?
- How to initialize an array ?
- How to access elements of an array ?
- Finally multidimensional arrays are described if you're interested.
thekashyap
Practically a Posting Shark
811 posts since Feb 2007
Reputation Points: 254
Solved Threads: 75
Wow! That's some scary looking code you've cooked up!
Why don't you grab a copy of the c++ primer or some book like it. Go through it completely before attempting something like this. I think you are just going to confuse the hell out of yourself if you keep going in this way.
Just a tip from another code neophyte...
Here's a snippet to get the input into an array:
int arr[5];
int i =0;
int x;
while (i<5)
{
cin >> x;
arr[i] = x;
i++
}
JRM
Practically a Master Poster
621 posts since Nov 2006
Reputation Points: 130
Solved Threads: 75
Since the frequency is initialized with 0 and can hold a maximum value of 5, we can also write:
if(frequency != 5)
cout << "\nThere are" << frequency << " number of your prediction that matches";
else
cout << "Congratulation!! All of Your Prediction Matches ";
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734