catching up with past lecture examples
This commit is contained in:
parent
f588c6dd36
commit
54a0bff29a
|
@ -0,0 +1,28 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
int num = 0;
|
||||
|
||||
cout << "Enter an integer" << endl;
|
||||
cin >> num;
|
||||
|
||||
//while(num = 1){
|
||||
// cout << "Enter a non-one number: ";
|
||||
|
||||
// cin >> num;
|
||||
//}
|
||||
|
||||
//cout << "What does assignment return?: " << (num = 10) << endl;
|
||||
|
||||
if(num == 0 && true){
|
||||
cout << "Print true" << endl;
|
||||
}
|
||||
else {
|
||||
cout << "Print false" << endl;
|
||||
}
|
||||
|
||||
cout << "You got out" << endl;
|
||||
return 0;
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
int count = 0;
|
||||
for(int i=0; i < 8; i++){
|
||||
for(int j=0; j < 9; j++){
|
||||
for(int k=0; k < 10; k++){
|
||||
count = count + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << "Loops ran: " << count << " times" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
char opt;
|
||||
cout << "Welcome: type an option and hit enter to proceed" << endl;
|
||||
|
||||
double grade = 3.2;
|
||||
string studentID = "ccl1234";
|
||||
bool hasBribed = true;
|
||||
|
||||
cout << "(a)" << "Check grade " << endl;
|
||||
cout << "(b)" << "Student ID" << endl;
|
||||
cout << "(c)" << "Has Bribed Professor" << endl;
|
||||
|
||||
cin >> opt;
|
||||
|
||||
switch(opt){
|
||||
case 'a':
|
||||
cout << "Your grade is: " << grade << endl;
|
||||
break;
|
||||
case 'b':
|
||||
cout << "Your student ID is: " << studentID << endl;
|
||||
break;
|
||||
case 'c':
|
||||
cout << "Have you gamed the system?: ";
|
||||
if(hasBribed){
|
||||
cout << "The scandal of it all" << endl;
|
||||
}
|
||||
else{
|
||||
cout << "You have regained humanity" << endl;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
cout << "Sorry I didn't understand that" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
char option;
|
||||
|
||||
cout << "Enter any letter (but q exits)" << endl;
|
||||
cin >> option;
|
||||
|
||||
while(option != 'q'){
|
||||
switch(option){
|
||||
case 'a':
|
||||
cout << "You pressed a" << endl;
|
||||
break;
|
||||
case 'b':
|
||||
cout << "Bee is a bug" << endl;
|
||||
break;
|
||||
default:
|
||||
cout << "That's a nice letter too" << endl;
|
||||
}
|
||||
cout << "Enter any letter (but q exits)" << endl;
|
||||
cin >> option;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
|
||||
char option;
|
||||
char option2;
|
||||
|
||||
cout << "Enter a letter: ";
|
||||
cin >> option;
|
||||
cout << "Enter another: ";
|
||||
cin >> option2;
|
||||
|
||||
switch(option){
|
||||
case 'a':
|
||||
switch(option2){
|
||||
case 'a':
|
||||
cout << "aaaaaaaa" << endl;
|
||||
break;
|
||||
case 'b':
|
||||
cout << "bbbbbbbb" << endl;
|
||||
break;
|
||||
default:
|
||||
cout << "I don't know what that means" << endl;
|
||||
break;
|
||||
}
|
||||
//break;
|
||||
case 'b':
|
||||
switch(option2){
|
||||
case 'c':
|
||||
cout << "ccccccc" << endl;
|
||||
break;
|
||||
default:
|
||||
cout << "Nope" << endl;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
cout << "Why" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue