Question
Redo the programming assignment from Homework 1 in C++. Replace all C input/output statements with C++ statements (cin, cout, cin.getline) to get the same formatted
Redo the programming assignment from Homework 1 in C++. Replace all C input/output statements with C++ statements (cin, cout, cin.getline) to get the same formatted output as Homework 1.
Requirements:
Do not use the header file stdio.h, use iostream
Must contain a function called isDivisible with the following prototype:
void isDivisible( int, int, bool &);
Discuss and find how you will use the parameters.
You must compile your code using g++ command on UH Unix using the appropriate compilation options described on the course main page.
FAQ
For this assignment, I am prohibited from using stdio.h, but can I use other C header files, e.g., stdlib.h? - Yes, you can include them. You can also use specific forms to specifically include C header files, e.g., cstdlib
Do I need to submit a Makefile?
- No.
Do I need to consider a specific case for testing?
- No, just give an ordinary case to show that your program runs correctly.
Your submission must include the following:
Source Code
Proof of compilation
Output with ONE test case.
--------------------------------------------------------------
Homework 1 :
Contains a user-interface function which requests the user to enter a integer, and returns the given integer.
If the given value is a character or string, the program must display an error message and prompt the user to enter an integer. You only need to test for the input of characters and integers. You do not have to worry about floats being entered.
If the given number is less than or equal to 0, the program must display an error message and prompt the user to enter a positive integer.
Contains a print function which uses a for loop to generate a list of factors starting from 1 to the given number itself with indeces. (see the sample below)
Contains a function called isDivisible with the following prototype:
int isDivisible(int,int);
The table must be formatted. (see the sample below)
Columns must be right-aligned.
No. | Factor |
1 | 1 |
2 | 2 |
3 | 3 |
4 | 4 |
5 | 6 |
6 | 8 |
7 | 9 |
8 | 12 |
9 | 18 |
10 | 24 |
11 | 36 |
12 | 72 |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started