The following coding conventions should be used for all assignments.
Have a comment section at the top of your files with your name, the
assignment number, the date the code was written and the purpose of the
file. Optionally, you may also have notes about changes made to the file
since the original was coded. Such notes can often help you keep track of
the changes you have made as you refine a project.
Put a blank line between each function body (including between main and
user defined functions), between the header section (#include and using
namespace) and the function prototype section, and between the function
prototypes and the main function.
Indent all blocks such as if statements or loops with at least two
spaces. For example, your if statements should appear as:
if(a == b)
{
a = a * 2;
b = b - 1;
}
NOT as:
if(a == b)
{
a = a * 2;
b = b - 1;
}
There are two parts to this assignment. Each part is worth 10 points. Name your
files hw1_1.cpp for part 1 and hw1_2.cpp for part 2.
Write a recursive function that will take an integer and print its digits
in reverse order. For example, if given the number 321, it will print 123.
Your function MUST take an integer, not a string. Your main function
should prompt the user to enter an integer and then print the reversed
integer to the screen.
Hint: n % 10 will get the last digit of an integer.
Write a structure called ProductInfo for a small inventory control system.
Your ProductInfo structure will have the following pieces of data:
A string for the product name
A string for the product description
A 13 character string for the UPC (Universal Product Code)
An integer for how many of that product are in stock
Create the following two functions to manipulate ProductInfo objects:
addProduct - Has one ProductInfo object as a parameter. It will set the
name, description, UPC and amount in stock for that product.
showProduct - Has one ProductInfo object as a parameter. It will display
the name, description, UPC and amount in stock for that product.
Your main function should do the following steps:
Prompt the user for the number of products they wish to add to the
inventory and read the response in.
Validate that the integer given by the user is greater than 0.
Dynamically allocate an array of ProductInfo objects using the integer
given by the user.
For each object in the ProductInfo array, call addProduct
For each object in the ProductInfo array, call showProduct