Skip to content

Instantly share code, notes, and snippets.

View DanielDe's full-sized avatar

Daniel de Haas DanielDe

View GitHub Profile
@DanielDe
DanielDe / badStyle.cpp
Created October 8, 2012 05:38
CS 10 SI Classroom Session 1 - Bad Style Example
#include <iostream>
using namespace std;
int main(){
cout<< "Enter the radius of a circle:";
int a;
cin >> a;
double b=3.1415926535;
@DanielDe
DanielDe / randExample.cpp
Created October 15, 2012 06:13
CS 10 SI Classroom Session 3 - rand() and srand() example
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
// test the rand() function a few times
cout << rand() << "\n"
<< rand() << "\n"
@DanielDe
DanielDe / ifExample.cpp
Created October 15, 2012 06:34
CS 10 SI Classroom Session 3 - if statement example
#include <iostream>
using namespace std;
int main() {
// finding the maximum of two numbers
int num1, num2;
cout << "Enter two numbers: ";
cin >> num1 >> num2;
@DanielDe
DanielDe / inputValidation.cpp
Created October 22, 2012 07:20
CS 10 Classroom Session 4 User Input Validation
#include <iostream>
using namespace std;
int main() {
int score1, score2;
// collect score 1
cout << "Enter your score on the first exam (0 - 100): ";
cin >> score1;
@DanielDe
DanielDe / pow.cpp
Created October 29, 2012 03:54
CS 10 SI Lab Session 5 - pow
#include <iostream>
using namespace std;
int main() {
double b;
cout << "Please enter a base number: ";
cin >> b;
int e;
@DanielDe
DanielDe / ex3p1.cpp
Created November 3, 2012 21:54
CS 10 SI Lab Session 5 Exercise 3 Solutions
#include <iostream>
using namespace std;
void print_rect(int, int); // we declare the function here
int main() {
int w, h;
// We generally prompt the user for input in the main function
@DanielDe
DanielDe / ex4find.cpp
Created November 8, 2012 18:50
CS 10 SI Week 6 Lab Exercise Solutions
#include <iostream>
using namespace std;
string extract_bold(string);
int main() {
string test1 = "To <b>succeed</b> in <b>life</b> one must be <b>bold</b>!";
cout << extract_bold(test1) << endl;
@DanielDe
DanielDe / Exercise 1 Solutions
Created November 17, 2012 05:48
Week 7 Lab Exercise Solutions
a. 10
b. 10
c. 10
d. 21
e. infinite loop
f. 11
g. 7
@DanielDe
DanielDe / ex1.cpp
Created November 21, 2012 05:07
Week 8 Lab Exercise Solutions
/*
This code is based on the first solution I posted for exercise 4 from Week 6. I placed a MODIFIED comment anywhere I changed the code.
*/
#include <iostream>
#include <vector>
using namespace std;
vector<string> extract_bold(string);
@DanielDe
DanielDe / ex1.cpp
Created December 1, 2012 22:07
Week 9 Lab Exercise Solutions
#include <iostream>
#include <vector>
using namespace std;
void remove(vector<int>&, int);
void print(const vector<int>&);
int main() {
vector<int> v;