New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

CS 1336 Study Guide for First Midterm

by: Nicole Notetaker

CS 1336 Study Guide for First Midterm CS 1336-

Marketplace > University of Texas at Dallas > CS 1336- > CS 1336 Study Guide for First Midterm
Nicole Notetaker
GPA 4.0

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

This study guide goes everything that was covered in Chapters 1 through 3, and should be very helpful in studying for the upcoming midterm. (And hey! It could probably all fit onto one page! *wi...
Programming Fundamentals
Karen Mazidi
Study Guide
c++, Studyguide, cs1336, midterm
50 ?




Popular in Programming Fundamentals

Popular in Department

This 7 page Study Guide was uploaded by Nicole Notetaker on Thursday September 22, 2016. The Study Guide belongs to CS 1336- at University of Texas at Dallas taught by Karen Mazidi in Fall 2016. Since its upload, it has received 23 views.


Reviews for CS 1336 Study Guide for First Midterm


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 09/22/16
P a g e  | 1 CS 1336 Midterm Study Guide Chapters 1­3  Computer Hardware Components  Central Processing Unit  Component that actually executes the program  Composed of control unit and ALU  Control Unit: coordinates program’s operations  Arithmetic Logic Unit: performs all the mathematical calculations  Main Memory  Composed of short term Random Access Memory  Data is stored in bytes (made of 8 bits), each assigned a numbered address and capable of storing one letter or number  Characters and numbers are stored as 1s and 0s; exact code for a given character is determined by ASCII  Secondary Memory  Includes disk drive, floppy disk, USB, CD, DVD, etc…  Latter types are useful for their portability  Long­term storage  Input Devices  Keyboard, mouse, scanner, etc… anything that can be used to input data into the computer  Output Devices  Monitor, printer, speaker, etc…  Software  Made of programs, divided into:  System Software P a g e  | 2  Operating Systems: controls basic/background operations of a computer, retrieves data from programs  Utility Programs: virus scanners, data­backup, and file compression software  Software development tools  Application Software: programs that users are actively involved with, like Microsoft Word and Powerpoint  Converting Source Code to Executable Code  What the programmer creates I C++ higher programming language is called the source code. The pre­processor then modifies the code by following any commands preceded by the # symbol, and includes the code contained within the specified header files in the newly modified source code. This then goes to the compiler, which will detect any syntax errors and convert the code to the object code. Finally, the object code is sent to the linker, which connects the code to the C++ run­time library (where the code from the header files is contained), creating an executable code in lower­level binary language.  Parts of a Program  Comments  Used to explain code to readers; ignored by compiler  Comment must be preceded by //, or surrounded by /* and */  Header Files  Used to include code from C++’s runtime library  Placed before main function  Follows #include <filenamehere> format  Called a pre­processor directive, because the # at the beginning of the statement causes the pre­processor to read the statement and include the named file, while the compiler ignores it  Header File Types  <iostream> : used in virtually every program, this file allows the usage of cin and cout in functions  <cmath> : allows use of higher level math functions P a g e  | 3  <iomanip> : allows you to format output with stream manipulators  <string> : allows you to use strings as variables  <cstdlib> and <ctime> : used in random number generation  To   generate   truly   random   numbers,   your   code   should   include   these statements: unsigned seed = time(0); srand(seed); and cout << rand();  To also limit the random numbers to a specific range (like 1­6, for sides of a die), assign const int MAX and MIN (6 and 1 in this case) and int die, and use the formula die = (rand() % (MAX – MIN + 1) + MIN), and then cout << die << endl;  Using namespace std;  This code is also required near beginning of program, before the main function  Int main()  Indicates the beginning of the program’s primary (main) function  The following code block must be enclosed in a set of braces {}, and is usually indented so the code is made more readable  Variables  Named storage locations in RAM that can hold 1 replaceable value  May only be used in program after it is defined  Called the scope of the variable  Sizeof operator will report how many bytes of data are used for a given variable  Example: cout << “The size of a variable is “ << sizeof(int) << “ bytes.\n”;  Data types (or, variable definitions):  Bool : only stores true or false values, where true = 1 and false = 0  Char : can store any single­digit character, enclosed in apostrophes  Character literals must be enclosed in single quotation marks  Int : stores integers (positive, whole numbers)  Smaller data type integer variables are short and unsigned short; longer ones are long and long long  Float : can store any positive real number P a g e  | 4  Larger numbers may be displayed in scientific or E notation  Double and long double can hold larger values than float  Double : can store any real number, positive or negative  Const : used to store a constant value; paired with standard data type  Example: const double PI = 3.14159265  String : when the header file <string> is included in a program, strings may be treated as variables  Auto : used in place of numerical data types, this causes the program to determine the best data type to use  Cin Object  Format: cin >> variablenamehere;  >> is called the  stream extraction operator; data input here is stored in the keyboard/input buffer  Prompts user to input a value for a given variable; will then store that value  for that variable until the end of the program (unless it is changed)  Cout Object  Format: cout <<  “put what you wish to be displayed here” << endl;  Like all statements, cout must end with a semi­colon  << endl is optional; it is used to end the current line on the display, and start a new one  Using \n within the quotation marks will do the same  The quotation marks and everything inside them are referred to as a string literal; cout is a stream object, and << is the stream insertion operator  Operators  Unary operators: require only one operand  negation operator (­) flips the sign of a variable­stored value  Binary operators: most common, require two operands  Associativity is left­right P a g e  | 5  Listed by precedence (the order in which the operators’ functions are performed)  * (multiplication), / (division), and % (modulus operator, finds the remainder when one integer is divided by another)  Note! When dividing two integers, if you want your answer to include any numbers after the decimal point, you must convert one of the integers into a floating point variable by adding .0 to the end; otherwise, the result will be truncated and only the digits preceding the decimal point will be shown  Example: 5 / 2 = 2, but 5.0 / 2 = 2.5  + (addition), ­ (subtraction)  The addition operator can also concatenate (connect) two strings into one  = (assignment operator): usually used to assign values to a variable  In initialization, the variable is assigned a value at the same time its data type is declared (so, int number = 7;)  Combined assignment operators : when you wish to manipulate the value stored in a certain variable, use +=, ­=, *=, /= and %=  Combined assignment operators have lower precedence than their standard counterparts  Example : x += 5 is equivalent to x = x + 5  <cmath> : inclusion of this header file allows for higher level math functions, like the power function, which is written as pow(variablename/number, exponent).  Other functions included in this file are absolute value, sin, cos, tan, exponents, log, ln, and square root  Type Conversion  When using operands of different data types, all operands are automatically promoted to highest ranking operand involved (in long double, double, float, long, int order), all char and short variables are promoted to int, and final value of expression is converted back to data type of assigned variable  If a value is too large for a variable, there is overflow, and the value cycles back around to the most negative number the data type can hold; likewise, if the value P a g e  | 6 is too small (negative), there is underflow and the value changes to the largest positive number the data type can hold  Type cast expressions let you manually promote or demote value, which is useful in preventing integer division  Example : when calculating average number of books read per month, for answer to be displayed as a decimal, use static_cast<double>(books)/months  Stream Manipulators  <iomanip> header file is required for the usage of all of these  setw(x)  is used to set the minimum number of spaces a given variable will be displayed with (where x is the number of spaces you wish to assign the variable)  if there are extra spaces, they will automatically be filled with blank spaces on the left (because the variable is right justified); if there are too many digits, they will still all be displayed­ just beyond the given field width  add left to statement to have the variables displayed to the left (= left justified)  format : cout << left << setw(4) << variable name << endl;  setprecision(x) determines the number of decimal points a variable will be displayed with  this, used with fixed, keeps values in fixed­point/decimal notation  format : cout << setprecision(x) << fixed;  this, used with showpoint, fills all the extra blank spaces after the decimal point with trailing zeros P a g e  | 7 Good luck on the exam!


Buy Material

Are you sure you want to buy this material for

50 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

Allison Fischer University of Alabama

"I signed up to be an Elite Notetaker with 2 of my sorority sisters this semester. We just posted our notes weekly and were each making over $600 per month. I LOVE StudySoup!"

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Parker Thompson 500 Startups

"It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.