From ce12e5fd0c7be54069637e5896872c6d248d93c0 Mon Sep 17 00:00:00 2001 From: Lloyd Crawford Date: Wed, 19 Oct 2022 20:46:02 -0700 Subject: Here is my 2nd attempt to upload my HW Ch9 Debugging. --- .../CST116-Ch9 Debugging-Pseudocode-Crawford.txt | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 CST116-Ch9-Debugging/CST116-Ch9 Debugging-Pseudocode-Crawford.txt (limited to 'CST116-Ch9-Debugging/CST116-Ch9 Debugging-Pseudocode-Crawford.txt') diff --git a/CST116-Ch9-Debugging/CST116-Ch9 Debugging-Pseudocode-Crawford.txt b/CST116-Ch9-Debugging/CST116-Ch9 Debugging-Pseudocode-Crawford.txt new file mode 100644 index 0000000..091a23e --- /dev/null +++ b/CST116-Ch9-Debugging/CST116-Ch9 Debugging-Pseudocode-Crawford.txt @@ -0,0 +1,59 @@ +Include standard operation parameters +[#include +using std::cout; +using std::cin; +using std::endl;] + +*Simulate age of person and how old they are in days. +const int DAYS_PER_YEAR = 365; + +int GetAge(int &a); +int CalcDays(int age); +void PrintResults(int age, int days); + +int main() +{ + int age = 0; + int days = 0; + // Breakpoint 1 + // Put breakpoint on the following line + cout << "Breakpoint1age=" << age << "days=" << days << "address of age" << &age << endl; + + GetAge(age); + days = CalcDays(age); + + // Breakpoint 2 + // Put breakpoint on the following line + cout<<"Breakpoint2age="<< age << "days = " << days << "address of age" << &age << endl; + PrintResults(age, days); + + return 0; +} +* Part 1&2 Get the age of the user +*return a non-0 on an error, 0 otherwise + +int GetAge(int &age) +{ + cout << "Breakpoint age=" << age << "At Address:" << &age << endl; + cout << "Please enter your age: "; + cin >> age; + cout << " Breakpoint age = " << age << " At Address: " << &age << endl; + return age; +} +*Past section calculates the number of days in years +*set year parameter, Number of Years + +int CalcDays(int years) +{ + int days; + days = years * DAYS_PER_YEAR; + + return days; +} +void PrintResults(int days, int age) +{ + cout << age << "! Boy are you old!\n"; + cout << "Did you know that you are at least " << days << " days old?\n\n"; +} +*This prints the number of years & days to the screen with message +Shows age in days and years. \ No newline at end of file -- cgit v1.2.3