C++ Coding Help

military_irish

New member
Messages
4,725
Reaction score
304
For anyone that can assist me.

I am trying to learn the coding system. I took a class a few years ago and passed with a B without ever attending a class except to take the exams.

A friend of mine is now taking the same class but at a different university. All the projects are pretty much the same. I offered my assistance. As I started helping out I realized I remember little to nothing.

I am slowly gaining my knowledge back but does anyone know a website where I can test my code or would anyone being willing to help put together a code I need?

I would really like to comprehend all of it (for my own personal gain) but I also want to be a good friend and help tutor my friend considering I said I understood it but now have no idea. lol
 

Andy in Sactown

Can't wait 'til gameday.
Messages
2,689
Reaction score
327
Do a lot of coding. Get a good book and do all the challenges. It's not a skill one gains over a weekend. It needs a lot of work to gain proficiency. There's a reason we're referred to as computer scientists/engineers.

Perhaps it would be more productive to express what you're trying to do.. I dunno.. you're a toe deep in an ocean of work.
 
Last edited:

military_irish

New member
Messages
4,725
Reaction score
304
Right now the "goal" is to create a code to produce this.

1 2 3 4 5 6 7 8 9

1 2 3 4 5 6 7 8

1 2 3 4 5 6 7

1 2 3 4 5 6

1 2 3 4 5

1 2 3 4

1 2 3

1 2

1

then produce this...

*************

*************

*************

*************

*************

then this...


============

* *

* *

* *

* *

* *

============

All are seperate projects. I will like to help my friend get a good grade but also I would like to understand the language for my own benefit
 

Andy in Sactown

Can't wait 'til gameday.
Messages
2,689
Reaction score
327
I can write a program that does that, but where are you at? You want to help your friend, but doing someone else's homework leaves a bad taste in my mouth.

Like I said, you can get a good book and teach yourself, but challenges are what makes you better. I thought I was a pretty good programmer, but after taking two years of classes and then took an upper level course (data structures), I realized you need a certain proficiency to tackle big problems.
 

military_irish

New member
Messages
4,725
Reaction score
304
If I remember correctly I would start the row by writing....

#include<iostream>
{
for( int a = 1; a < 10; a = a + 1)
{for (int b = 1; b<9; b=b+1)
}
}

but thats just for a row and not a column if that makes sense. if not just point me in the right direction
 
C

Cackalacky

Guest
That is a counter basically. There are several ways to accomplish that. Loops, if then commands, define initial setup and count down..... google has tons of examples. Like others said, though the struggle makes the knowledge worth the effort.
 

military_irish

New member
Messages
4,725
Reaction score
304
Thank you. Although I am helping a friend i actually want to gain the knowledge of putting together the codes. So the challenge is fun to me
 

military_irish

New member
Messages
4,725
Reaction score
304
Can anyone help with this question? I have a code written but whenever I write it in this post it messes up. Here's the question.
I can send my code if someone is willing to look it over for me




Write a program that simulates a lottery. The program should have array of 6 integers namedMichiganwinning_numbers, with a randomly generated number in the range of 1 through 9 for each element in the array.Michigan The program should ask user to enter 6 numbers and store them in another integer array namedMichiganplayer. The program then compares the numbers in 2 arrays to find out how many numbers match. The program output should display the winning numbers, player’s numbers, and how many numbers matched. For instance, if your winning_numbers are 3,5,9,1,4,7Michigan and your player’s numbers are 2,5, 7,1, 9,8, then you have two matches (5 and 1).

Input Validation: Do not accept player’s number out of range of 1-9.
 
Last edited:

ulukinatme

Carr for QB 2026!
Messages
31,523
Reaction score
17,410
code 1st part



code 2ndpart

I'm on my phone so it won't let me post the picture for some reason. I just get the blue "x"

I'm trying to download Visual Studio Express right now to test, but it looks like you have most of it right.

You're still missing the number validation (1-9). You can do a "Do While" loop inside the "For" loop on the number input, with the while loop terminating once the player enters a correct number each time, then allow the for loop to increment and do the "Do While" again.

Got a question on the number matching...what exactly is the required output? Your code suggests it's just a boolean value if any numbers match or not, but in your instructions it says to list how many numbers are matching. If it's the later, you'll need to change the boolean to an int, and then increment it each time a number matches.

What was the actual problem you were having with the code? Was it a compiler error, or logic?
 

military_irish

New member
Messages
4,725
Reaction score
304
I'm trying to download Visual Studio Express right now to test, but it looks like you have most of it right.

You're still missing the number validation (1-9). You can do a "Do While" loop inside the "For" loop on the number input, with the while loop terminating once the player enters a correct number each time, then allow the for loop to increment and do the "Do While" again.

Got a question on the number matching...what exactly is the required output? Your code suggests it's just a boolean value if any numbers match or not, but in your instructions it says to list how many numbers are matching. If it's the later, you'll need to change the boolean to an int, and then increment it each time a number matches.

What was the actual problem you were having with the code? Was it a compiler error, or logic?


I'm glad you want to help but Woneone helped me out and he was able to get the right output. Sorry but thank you at the same time.
 

ulukinatme

Carr for QB 2026!
Messages
31,523
Reaction score
17,410
Fair enough. If I could give your buddy any advice, I'd say to do all the exercises requested by the prof and then some. I tried to BS my way through C++ the first time, didn't work out so well and I had to retake it. Much like a foreign language, you want to spend time practicing it outside of the normal classroom experience if you want to be proficient in it. Once you learn one language it becomes rather easy to pickup another. It's all about understanding the concepts, once you get that down it's just a difference in syntax between the languages.
 
Top