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
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