You need to improve your keyboard input routines. I’ve tidied it up slightly but if you enter a character then your program will crash.
If you reference your grade array with an index > 24 then...
Type: Posts; User: Michael432000
You need to improve your keyboard input routines. I’ve tidied it up slightly but if you enter a character then your program will crash.
If you reference your grade array with an index > 24 then...
Thank you nick. But you don’t owe me anything, its been a pleasure to share the little bit of c++ knowledge I’ve learnt. And lots of very nice people on this forum have helped me too, so we all move...
Syntax for your if statements is wrong.
if ((score >= 90) && (score <= 100)) A_count++;
score++;
Well, the data you presented is a bit confusing because it suggested input from a file, 2 scores: 80, 97; 5 scores: 69, 79, 89, 99, 58; etc
And also you have stated above: ‘No input will be...
This should get something printing out for you, which will hopefully make it more clear.
int main()
{
////////////int row[100] = {0};
////////////int column[100] = {0};...
Don’t worry; when you get it working and the results are printed out it will make more sense to you.
Don’t forget, you are only printing out the results for successful attempts, so if the mole...
Here’s something to get you started if you’re still stuck.
But you need to find out where your data is and how you are going to access it.
Note: I have a propensity for using for loops, but...
Yes.
But, the break statement simply breaks out of the current loop.
In the above code the next statement to be executed would be the main for loop with i incremented by 1, and off we go again.
You’re doing fine, keep going, I’m not very good at explaining things, lol.
Ok, so it’s an 8*8 grid and if the mole is at position (3,8) and the next move is to the right, then he reaches the...
Call to srand() goes at start of program before the loops.
Make sure you understand what the rand statement is doing.
I noticed you coded rand() % 5.
When rand() returns a value of 10,...
First thing, decide whether your grid is 8X8 or 9X9, you keep changing.
Now on a piece of paper, draw a grid like a chessboard, 8x8.
Now number the squares along the top from 1 to 8 going from...
Q2.
name has 36 characters, 0-35
when rand() returns 36, or 73, or 110 etc etc
36 mod 37 = 36 = space
73 mod 37 = 36 = space
so use mod 36
*
Start position: row[0] = 3, col[0] = 2 index 0 of row array contains value 3
Move right: row[1] = 3, col[1] = 3
Move right: row[2] = 3, col[2] = 4
move down: row[3] = 4, col[3] = 4 ...
Why not start off with a simplified version, whereby the number of moves per game is restricted to say 100, else failed attempt. Then you can easily get started with one-dimensional arrays.
...
I’m happy to show you how to do this if it’s not too late.
Yes, with two, if you’re happy to use a simple if else statement.
Goodness me, that’s way too complicated, lol.
It can be done with 3 integers.
Walkthrough: Compiling a Native C++ Program on the Command Line (C++)
But using the Visual Studio IDE (Integrated Development Environment) is much better. Just create an empty project and add a...
You could use just one array and hold the card number, 1 of 52 possibilities, as an integer.
Let’s say there are 100 hands of 5 cards.
Int My_hand[100][5];
8 of Clubs
King of Diamonds
3...
Thank you for the explanation. It all works fine now.
Of course I don’t wish to use this code. I just want to understand it so I can write my own, tailored to my own needs.
Thanks for sharing.
Hi Whiteflags! Lol, I’m working with Elysia’s code, which I got compiled at last.
The code I posted (#3) was just to show a fellow beginner programmer that there are alternatives you can mess...
That code is too advanced for me too, at the moment, but I will keep working on it, or towards it.
If that boost library is a dead dependency, then what about the reference to boost on line 16?
...
You can mess around with strings and things.
I like this method but I don’t know if this is good or bad practise.
#include <iostream>
#include <string>
#include <sstream>
using namespace...
I saw from your previous thread that you were struggling with functions.
Here, the function menu() uses the return statement to return choice: Notice the function is declared above main() and...
Ah, real code, that’s what I’m looking for. Really appreciate you posting this, thank you. Beautiful.