C++ Learners
Forum for assignments and discussion among C++ Study Group
19 topics in this forum
-
- 6 replies
- 89 views
Today we speculated on how to get AI to do mundane tasks like closing 5 point patches in A:M. I think the rules for 5-point patchs are like this... A patch is a set of 3, 4 or 5 CPs connected by two or more splines. Each CP in the set is connected by splines to two and only two other CPs in the set. For any two CPs in the set, a spline that connects them has no other CPs between the two CPs. (This will be true only for patches in which each side is a different spline.) [some rule about how the splines can be followed to loop around the patch to all the other CPs and return to the starting CP] If a set of five points meets those rules …
Last reply by Rodney, -
- 0 replies
- 441 views
Lesson 28 (Return Values) shows how to get a value back from a function. Lesson 29 (Parameters) shows how to send values to a function We can show what we learn in one program Assignment program Write program with at least two functions. One function when called will prompt the user for an item of data and return that data to the main program. The second function, when called, is sent that data as a parameter and returns the result of some calculation on that data. The main program will display that returned result. Remember to label your outputs. Possible topics Area of a square or any other geometric figure …
Last reply by robcat2075, -
- 1 reply
- 224 views
Multi-dimensional arrays let you store tables of date. Nested loops make it easy to populate and output these tables. John Purcell suggests a multiplication table exercise. In addition to outputting the whole table, choose a few random array elements and output their values. The output will look like this. Format your output neatly! Mult Table! 1 2 3 4 5 6 7 8 9 10 2 4 6 8 10 12 14 16 18 20 3 6 9 12 15 18 21 24 27 30 4 8 12 16 20 24 28 32 36 40 …
Last reply by robcat2075, -
- 0 replies
- 130 views
John Purcell introduces functions, a form of reusable code. When you invoke a function, that causes the program to depart to another portion of your code, execute it, then return to just after the original function call. This first lesson on functions does not yet consider the important function return values or function parameters, but those are coming. Sample lesson idea: Copy the code of your Case and Switch program into a new C++ project and modify it to print the opening title and explanation via a function that is called, rather than having those hard coded into the main() loop of your program If your Case and Switch program didn't have an o…
Last reply by robcat2075, -
- 0 replies
- 196 views
The switch structure simplifies situations that might be done with an if and many else ifs but only consider an integer value to decide which else if to do. sample project Golf scores are integers, so are the "par" values for the holes. A player's score on a hole can be just a number but it is often described by how many strokes above or below par it was. Also, there are names for each specific above or below possibility Write a program that prompts the user to input a par for a hole and the players number of strokes on that hole. Output par for the hole, the player's strokes, how many strokes above or below par he was and the golf word f…
Last reply by robcat2075, -
- 0 replies
- 212 views
It wouldn't be hard to memorize the sizes of standard data types and hard code those when programs needed to use them. But part of the power of C++ is that you will be able to create your own data types... and make arrays of them, which could be any length. sizeof() helps you to bullet proof your code so that even if you change the size of your data type or the length of an array, your code can still operate on them without over-running or under-running the total data. project. Write a program that declares an array of strings without specifying a specific number of elements and initializes the elements with a set of data in that same declaratio…
Last reply by robcat2075, -
- 0 replies
- 313 views
Arrays let you store a set of data under one name. Arrays can be a set of almost any data type, even one you created your self. Sample Project Write a program that prompts the user for 5 items of data, then prints the 5 items back out. Example output... I'm Using Arrays! ---------------- Enter a name: Crusty Enter a name: Dusty Enter a name: Musty Enter a name: Lusty Enter a name: Bartholomew These are the names you entered... Name 0 Crusty Name 1 Dusty Name 2 Musty Name 3 Lusty Name 4 Bartholomew Done! John Purcell suggested a program that stores the multiples of 12 in an array and then prints them out. The output m…
Last reply by robcat2075, -
- 0 replies
- 342 views
Note: this post is incomplete yet and needs some editing. Starting a new MFC "Single Document Interface" style program in Visual Studio 2022. The second video in this playlist of MFC tutorials demonstrates the basics of getting a plain-generic Windows program authored in Visual Studio 2015 This post is to document the difference between what is shown in that video and the current situation in VS 2022. Video time - 0:35 Add new Project to solution (this presumes you already a "solution" loaded in VS) (In this image I am adding the new Project to an existing folder in an existing solution) Choose MFC App, then Next …
Last reply by robcat2075, -
- 0 replies
- 198 views
Chapter 21 Break and Continue Break and Continue give you ways to bypass instructions in a loop When break is encountered the program skips to the end of the loop and regards the loops as finished Exercise: copy your Week 10 X-maker program code to a new project and modify it with break so that it only prints a maximum of 10 Xs Example output Making Xs! How many Xs do you want? 6 XXXXXX How many Xs do you want? 2 XX How many Xs do you want? 25 XXXXXXXXXX How many Xs do you want? 57 XXXXXXXXXX How many Xs do you want? 0 I'm done! When continue is encountered, execution skips to the end of the loop, but then return…
Last reply by robcat2075, -
- 0 replies
- 188 views
Tom Scott, the YouTuber so nice they gave him first names twice, has a lucid discussion of the precision problem of floating point numbers on binary computers. @Rodney @Roger @Shelton
Last reply by robcat2075, -
- 0 replies
- 199 views
Lesson 20 For Loops Do this for your assignment: Make a program that will prompt the use for a number from 0 to 60 and print out a row of that many Xs. If the entered number is 0 the program exits. Sample run: Rows of Xs! How many Xs do you want? 8 XXXXXXXX How many Xs do you want? 13 XXXXXXXXXXXXX How many Xs do you want? 0 We're done! This project uses both "for loop" and your recently acquired "do while" skills. Hint: First write and test a for loop that prints out a row of n Xs. @Roger @Rodney @Shelton
Last reply by robcat2075, -
- 0 replies
- 211 views
Lesson 18 While Loops Finally, we can make a program repeat steps! Project idea: John Purcell suggests a program that uses a while loop to do something a number of times. But that's lame, that's what For loops are for. How about... implement the "Price Is Right" guessing game, where the user enters a guess at a secret number, then the computer answers "High" or "Low" or "Correct". Repeat that while the user has not yet guessed the secret number. Lesson 19 Do While Loops Do While is ideal for situation where some condition isn't tested or step isn't done until you are in the loop and that step or test needs to be repeated until it meets…
Last reply by robcat2075, -
- 0 replies
- 256 views
Lesson 16 Comparing Floats Turns out... floating point numbers are never quite what they seem. Program idea: write a program to test if a float variable set to 1.1 will be evaluated as equal to, greater than or less than 1.1 When that is known, add tests to the program to see how little needs to be added (or subtracted) to the explicit value to make the evaluation with the variable come out differently from before. Program idea: A bit of code like this will show that a floating point variable set to 1.1 will evaluate as greater than a literal 1.1 float myVariable; myVariable = 1.1; if (myVariable > 1.1) { cout>> "myVariable is greater…
Last reply by robcat2075, -
- 2 replies
- 291 views
Lesson 12 Bools and Chars This completes our set of classic Data types everyone should know. Idea for project: Declare a couple of Boolean variables. Set one equal to true and the other equal to false. Print out the values of both. Label your output. Declare a char variable and set it equal to a value. Print out both its character value and its integer value. Label your output. Declare a second char variable and prompt the user to give a value for it. Print out both versions of the char value. Label your output. Lesson 13 If "If" is our first "decision structure." We can start getting the computer to make choices. Idea for pr…
Last reply by Rodney, -
- 3 replies
- 296 views
Lesson 10: Integer Types Integers are whole numbers and the computer can store their exact values... within certain ranges. John Purcell shows how to use the <limits> constants to find the min and max allowed values of different types of ints, and how to use "sizeof" to see much RAM they take. Assignment: There are at least 10 distinct types of integers in C++ Pick at least four types. In your program, declare an instance of each type, assign it a value, output the values. Conclude the program with a display of the minimum value, maximum value, and "size" for each of your four types type. Label your output! Lesson 11: Float…
Last reply by robcat2075, -
- 0 replies
- 183 views
We're in the "Basic Syntax" section. Everything in these lessons 6-26 are things you will want to be fluent in. You will need to call them up to your fingers over and over when you are programming. Lesson 8 User Input Now you can finally make a program the user interacts with! The cin statement allows you to get input from the user. Project... ask the user for several related numbers (or text!) then do some relevant processing of them Example project idea: ask the user for their birth year and the current year, then calculate their age. Remember to clearly prompt the user for input and clearly label your output. Lesson 9 Binary Number…
Last reply by robcat2075, -
- 2 replies
- 249 views
Lesson 6 - Variables Numeric variables are introduced in this lesson. Assignment: declare several integer variables and assign values to them, output them with meaningful labels, then output their sum. Lesson 7 - Working With Text String variables and simple operations on them are introduced. Declare several string variables, assign values to them and output them. Also show concatenation of them. And don't forget the Week 2 assignments if you haven't done them yet. Get started early! Don't wait until Sunday! @Rodney @Shelton @Roger
Last reply by Shelton, -
- 3 replies
- 313 views
We're rolling! Assignment for Week 2: Everything in Week 1 if you haven't done it already. Watch Lesson 1 in the Udemy course. No assignment. Skip Lessons 2 and 3. They are mostly about John Purcell's particular Mac environment. Watch Lesson 4. Assignment: Your own "Hello world" program, typed from scratch. Watch Lesson 5. Assignment: Make a program that will print a picture made with several lines of "cout" text. Tips: Watch John Purcell type in his programs and type in the same into your Visual Studio. Do all the little tests and experiments that he does along the way. Use the skills you learned to make you…
Last reply by robcat2075, -
- 1 follower
- 1 reply
- 343 views
@Rodney @Roger @Shelton Robbie For our first meeting you will want to get four things done. Download and install Microsoft Visual Studio 2022 "Community" edition Sign up for a free account to Udemy.com. Enroll in free Udemy course "C++ Tutorial for Complete Beginners" and watch Lesson 1 "Introducing C++" Get a personal Google Account so you will be able to attend our Google Meet sessions. Get the computer you will use to do C++ set up with a microphone and earphones so you can participate in our Google Meet session. No camera needed. Getting Visual Studio... Go to https://visualstudio.microsoft.com/downloads/ and choo…
Last reply by Shelton,