L3DynamicArraysnClasses PDF
Document Details
Uploaded by HardierHeliotrope7946
Tags
Summary
This document outlines programming concepts, including arrays, pointers, and dynamically allocated memory. Topics are explained using examples. It has questions in relation to the topics covered.
Full Transcript
Quiz on Wednesday Short, low stakes On paper On the material covered the last two weeks (mostly review, the stuff you used in the lab) Idea: Get you used to writing and reading code (t...
Quiz on Wednesday Short, low stakes On paper On the material covered the last two weeks (mostly review, the stuff you used in the lab) Idea: Get you used to writing and reading code (think whiteboard in interview process) Get you used to the style of questions I ask Add a level of bi-weekly review of material so you don’t have to cram for exams Tie Dye Event: Announcements Tuesday Night, 6-8 2nd floor Smith Hall Bring anything you want to tie dye (a department/university t-shirt/sweat shirt?) and tie dye away! Stop by and say “hi” if you don’t want to tie dye anything! Next Lab Posted: Due Fri, Sept 20. Uses Matrices, classes, and objects If you need more info about this topic (From Pandemic): https://www.eecis.udel.edu/~yarringt/CISC220/Latest/Week2/week2.html Random Numbers: #include … int x = rand(); // generates a random number between 0 and a max number defined in cstdlib Problem: if not given a specific seed, it will always start with the same seed. So you will get the same sequence of random numbers. We want to give it a seed, and each time we run our program, we want a new seed. So we often use the current time as our new seed. To generate a seed using the current time: #include … srand(time(NULL)); // creates a seed based on the current time (down to the millisecond) // Only need to create a seed once in a program // Must create seed BEFORE you use rand for the first time. int x = rand(); // now rand uses this seed in the calculation of the random number. // Now you won’t always get the same sequence of random numbers Question: How would you generate a random number between 1 and 10? Math stuff: #include … double d = 200.374; int i = 100; int j = -100; cout