Skip to content

Instantly share code, notes, and snippets.

@paranoiacblack
Created October 11, 2012 14:10
Show Gist options
  • Save paranoiacblack/3872569 to your computer and use it in GitHub Desktop.
Save paranoiacblack/3872569 to your computer and use it in GitHub Desktop.
CS 10 SI Lab Session 2 - Variable matching
#include <iostream>
using namespace std;
int main() {
// Initializing variables. '?' means you should insert the correct type
// identifier.
? a = 42;
? b = false;
? c;
? d;
? e = -9.8;
string f;
getline(cin, c);
// Using variables. Any place where there is a '~', you should replace
// it with one of the previously declared variables .
cout << "The value of ~ is always the same." << endl;
// Vocabulary. Any '__' should be replaced with the appropriate phrase
// that makes sense here. This isn't codelab or the book, though. Multiple
// answers are accepted.
cout << "This is because ~ is a(n) __ type." << endl;
cout << "a * b will always evaluate to a __ value." << endl;
cout << "Consequently, a / b will always run into what error?" << endl;
// Question: Is this a valid assigment? What is b's value now?
b = a;
// Bonus: What does ASCII stand for?
cout << "Enter an ASCII value: ";
cin >> d;
cout << "The above two lines imply that d is probably of type __." << endl;
d = 'A';
// What will the result of this expression always be?
// How can you fix it to make it more accurate?
// (HINT): Consult an ASCII Table.
e = a / d;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment