- /******************************************************************\
-
*
-
* *
-
* Date: 09.06.2007 *
-
\******************************************************************/
-
// Example: num digit
-
// A
-
// B
-
// C
-
// D
-
// revnum.cpp: Reverses a 3 digit number using
-
-
// the % operator
-
-
//
-
-
-
#include <iostream>
-
-
using namespace std;
-
-
-
-
int main()
-
-
{
-
-
int num, digit;
-
-
cout << "\nEnter a 3 digit integer:";
-
-
cin >> num; // Step A
-
-
cout << "\nThe number in reversed order is: ";
-
-
-
-
digit = num%10; // Step B
-
-
num = num/10;
-
-
cout << digit;
-
-
-
-
digit = num%10; // Step C
-
-
num = num/10;
-
-
cout << digit;
-
-
-
-
digit = num%10; // Step D
-
-
num = num/10;
-
-
cout << digit;
-
-
-
-
cout << endl;
-
system ("PAUSE");
-
return 0;
-
-
}
-
I can do the program but I have to answer the Example below the comment header showing the contents of the num and digit and I just dont understand it.
NUM DIGIT
A
B
C
D
i KNOW THIS SOUNDS CRAZY BU
7 2191
Um, could you rephrase your question? There was no example below, and that program seems like it would do something (I didn't run it, but if you can write it, I'm not sure what your question is....)
I have to show the contents of the digit and number variables number and the digit in A is
number and digit in B is
number and digit in C is
number and digit in D is
I have to show the contents of the digit and number variables number and the digit in A is
number and digit in B is
number and digit in C is
number and digit in D is
Okay, I'm still not following you. This can have any number of meanings. Does your professor want ASCII, do they want the compiler to do it?
say that I entered 123 as my three digit, then 321 would be the reverse I have to create a table that tells what is the NUMBER and the DIGIT be for STEP A is, and so on for STEP B,C,D
I dont understand it either would step A NUMBER be 123... but then what would the digit be
say that I entered 123 as my three digit, then 321 would be the reverse I have to create a table that tells what is the NUMBER and the DIGIT be for STEP A is, and so on for STEP B,C,D
I dont understand it either would step A NUMBER be 123... but then what would the digit be
Hmm, try modifying the program above to print out num as well. Then you should have num and digit through each section A, B, C, and D marked in the program with comments. Does that seem like what your prof would want?
say that I entered 123 as my three digit, then 321 would be the reverse I have to create a table that tells what is the NUMBER and the DIGIT be for STEP A is, and so on for STEP B,C,D
I dont understand it either would step A NUMBER be 123... but then what would the digit be
You mean:
num=123 -
-
-
-
STEP DIGIT NUM
-
--------------------------------------
-
A 123 123
-
B 3 12
-
-
-
-
-
-
-
something like that?
Compile and execute the following code. Trace through the program's flow as if you are the compiler or the computer. Create a table like the one below and place at the end of your "comment header" This table should shows the contents of the digit and num variables for each step.
TABLE BELOW
Example: num digit
A
B
C
D
// revnum.cpp: Reverses a 3 digit number using
// the % operator
//
#include <iostream>
using namespace std;
int main()
{
int num, digit;
cout << "\nEnter a 3 digit integer:";
cin >> num; // Step A
cout << "\nThe number in reversed order is: ";
digit = num%10; // Step B
num = num/10;
cout << digit;
digit = num%10; // Step C
num = num/10;
cout << digit;
digit = num%10; // Step D
num = num/10;
cout << digit;
Sign in to post your reply or Sign up for a free account.
Similar topics
by: muser |
last post by:
Karl this is albeit your program, in the program that you wrote for me
I learned quite alot, i didn't realise I could return NULL for
instance or even use functions without first declaring them,...
|
by: barb28 |
last post by:
Hello, sometimes I have noticed that
in web addresses, the number:
20%
will show up in the address. I think this is
somehow related to a 'blank space', but am
unsure, does anyone know about...
|
by: bridgemanusa |
last post by:
Hi All:
I have a very long page of html that I want to take portions and hide
them in divs, then show when a link is clicked. I have the hide show
part working when the link is clicked, however...
|
by: Kermit Piper |
last post by:
Hello everyone,
OK, let me try and explain again please. Here is what I'm trying to do.
I have a 12-digit
(UPC-A) javascript validation script which works great. All I need now
is a similar...
|
by: Candace |
last post by:
I am using the following code to pick off each digit of a number, from right
to left. The number I am working with is 84357. So for the first iteration it
should return the number 7 and for the...
|
by: Daniel Manes |
last post by:
I'm baffled. I have a column in a SQL Server Express database called
"Longitude," which is a float. When I view the table in a DataGridView,
some of the numbers, which only have two decimal places...
|
by: hikmaz |
last post by:
I am trying to get the rightmost digits (%10) of a number (taken from the user) and store it into successive array locations and get rid of the rightmost digit (\10) to store the next and so on and...
|
by: Sensei |
last post by:
Hi again!
I am trying to figure a simple example of a program that shows the
accuracy differences between float and double types. In particular I'm
searching for an operation that works on...
|
by: Jackmac |
last post by:
Hi there,
Hopefully an easy one for someone. I'm writing a small app (Visual Studio
2008) which will take an existing access database we have and show it in a
form I'm writing. The fields have...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |