diff options
Diffstat (limited to 'CST116-Ch9-Debugging/CST116-Ch9 Debugging-Pseudocode-Crawford.txt')
| -rw-r--r-- | CST116-Ch9-Debugging/CST116-Ch9 Debugging-Pseudocode-Crawford.txt | 59 |
1 files changed, 59 insertions, 0 deletions
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 <iostream> +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 |