====== Teaching C++ ====== [[http://docs.google.com/present/edit?id=0AVR-9e4hOpCbZGdnYnhiNnZfMTJ6amM4ZmN3&hl=en|Power Point]] main.cpp #include using namespace std; int main() { int value = 0; cout << "Enter an integer: "; cin >> value; cout << "You entered: " << value << endl; return 0; } build.sh gcc main.cpp -lstdc++ -o hello ===== Practice ===== ==== Test 1 ==== Compute the range of the projectile. Using a function to compute the following algorithm, ask the user to input angle and the velocity of the projectile. #include angleR = angleD * Pi / 180.0; range = sin(2.0 * angleR) * pow(velocity, 2) / gravity; ==== Test 2 ==== Guess a number between 1 and 100. First generate a random value between 1 and 100. Have the user enter a number that is between 1 and 100. Then create a function that will check if the number is to high, to low, or is the correct number. Then tell the whether the number entered was to high, to low, or correct. If the number entered was to high or to low, have the user enter another number. #include #include /* initialize random seed: */ srand( time(NULL) ); /* generate secret number: */ randomValue = rand() % 10 + 1;