Skip to content

Instantly share code, notes, and snippets.

View DanielDe's full-sized avatar

Daniel de Haas DanielDe

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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;