Question: in C++ Create a struct named Number. The Number struct represents a four digit number and should have 4 member variables for the Thousands, Hundreds,

in C++

Create a struct named Number. The Number struct represents a four digit number and should have 4 member variables for the Thousands, Hundreds, Tens, and Ones.

struct Number{ int thousands; int hundreds; int tens; int ones; };

Create a function that will add two variables of the Number type. Your signature should look something like this:

Number add(Number num1, Number num2);

Create a function that will take an integer as the argument and return a Number. This function should split a regular four digit integer into four separate numbers which will be used to set the member variables of the Number variable. For example, if the integer, 1234 is passed to the function, it will return a Number variable where thousands = 1, hundreds = 2, tens = 3, and ones = 4. The function signature should look something like this:

Number createNumber(int num);

If you'd like to challenge yourself, create a function that will divide to variables of type Number.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!