Functions Worksheet #1 Name -
  Day of Week -

Draw a console window and show the expected output for each code segment as precisely as possible.

1. 
#include <iostream>
using namespace std;

int add(int a, int b);
int main() { int num1 = 10; int num2 = 15; int result = 0; result = add(num1, num2); cout << result << endl; return 0; }// end of main
int add(int a, int b) { int sum = a + b; return sum; }// end of add
2. #include <iostream>
using namespace std;

double computeDiscount(int num, double price);

const double CLEARANCE_DISCOUNT = 0.2;
const double PRICE_PER_WIDGET = 20;

int main() {
   int numWidgets = 4;
   double discount = 0.0; double basePrice = 0.0; double finalPrice = 0.0; basePrice = numWidgets * PRICE_PER_WIDGET; discount = computeDiscount(numWidgets, PRICE_PER_WIDGET); finalPrice = basePrice - discount; cout << "The price after a discount is $" << finalPrice << endl; return 0; }// end of main

double computeDiscount(int num, double price) {
   return CLEARANCE_DISCOUNT * num * price; }// end of computeDiscount