Sign In | Subscribe
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Introduction to C++
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Related Services

Bookmark and Share
Lecture Comments (9)

1 answer

Last reply by: Alvin Sylvain
Sat Sep 26, 2015 4:57 PM

Post by Donald Sullenger on September 26, 2015

I can't come up with a valid solution to homework number 3.  The initial code (in number 2) worked as intended but I get an error when I add in the statement providing an invalid grade when < 0 or > 100.  I've also tried breaking that line into "if (rawGrade < 0 or > 100) {" and
"if (rawGrade < 0) or (rawGrade > 100) {" but I always get an error that it doesn't like the "or" (even if I use the || instead of the word).  Why?

#include "stdafx.h"
#include <iostream>
using namespace std;

int main ()
cout << "Welcome to the Easy Going University Grade System!" << endl;
cout << "Please enter the student's raw grade: " ;
int rawGrade;
cin >> rawGrade;

if (rawGrade < 0 or rawGrade > 100) {
cout << "Invalid grade!";

if (rawGrade > 60) {
cout << "You passed!" << endl;}

else {
int curve = (rawGrade * .5); // Determine amount of curve (50% of raw grade)
int curvedGrade = rawGrade + curve; // add curve to initial grade
cout << "The grade is curved by " << curve << " points." << endl;
cout << "Your total grade is " << curvedGrade << "." << endl;

if (curvedGrade <= 60) {
cout << "You failed!  No refunds!" << endl; }
else {
cout << "You passed!" << endl; }}
return 0;

2 answers

Last reply by: Mark Alvarado
Sat Feb 9, 2013 9:25 PM

Post by Jorge Guerrero on June 27, 2012

17 * 5 whatever that adds up to I'm not gonna work it out???? Jesus! What Master's Degree Professional doesn't know this right off the top of their head? It's 85! I'm sorry,, but I was cracking when I heard this.

This is the reason I think programming should be taught in schools as a shop elective where you can apply it to another field. No disrespect to programming majors, but if we teach our young students from grade school the basics, then have them keep on the course of taking programming as an elective, they'll become great programmers and professionals by the time they graduate college! Then they can go to grad school in any field of their choosing with this powerful skill: programming.

3 answers

Last reply by: Samuel Bass
Thu May 16, 2013 5:56 PM

Post by kristof anderson on June 14, 2012

where can i get the slide for the classes?


  • Branching allows program to process different code blocks depending on testable situations
  • Variables have a “scope” that is limited to the code block
  • The ‘if” statement processes a code block if its expression is true
  • The “else” clause processes a code block if the expression for its corresponding “if” statement is false
  • The ‘if” statement and/or its “else” clause may have more “if” statements nested in its code block
  • A special case of “else” nesting is the “chained if”, where a number of cases may be tested until one evaluates to true
  • A “switch” statement works like a “chained if” for an integer expression– the case that matches the integer value is processed
  • A “conditional” statement uses the “ternary operator” to provide a value conditional on its expression – the first value if true, or the second value if false
  • A “goto” statement unconditionally branches to another location in the code, but is known to lead to poor quality software
  • Here is a link that includes a discussion of various kinds of branching statements:


Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Overview 0:03
  • Code Blocks, Scope 1:32
    • 'Scope' of the Block of Code
  • Scope Example 2:56
  • 'If' Statement 5:20
  • 'Else' Clause 6:43
    • Example
  • Nested 'If' 7:52
    • Example
  • More Nested 'If' 8:41
  • 'If' Without Blocks 9:53
  • 'Chained If' 10:35
    • Example
  • 'If' Statement's Expression 11:36
  • 'If' Statement Stylistic Notes 12:55
  • 'Else' Clause Stylistic Notes 14:24
  • 'Switch' Multiple Choice 15:15
  • 'Switch' Like 'Chained-If' 16:35
  • 'Switch Tricks' 17:56
    • Leave Break Out
  • 'Conditional' Statement Cautions 19:54
  • 'Conditional' Statement Example 21:56
    • Another Example
  • 'Goto' and 'Label' 23:40
  • Do's and Don'ts 1:54