473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Show the contents of the digit and num

Expand|Select|Wrap|Line Numbers
  1. /******************************************************************\
  2. *
  3. *                                                                                     * 
  4. * Date: 09.06.2007                                                *
  5. \******************************************************************/
  6. // Example:           num    digit
  7. // A
  8. // B
  9. // C
  10. // D
  11. // revnum.cpp: Reverses a 3 digit number using
  12.  
  13. // the % operator
  14.  
  15. //
  16.  
  17.  
  18. #include <iostream>
  19.  
  20. using namespace std;
  21.  
  22.  
  23.  
  24. int main() 
  25.  
  26. {
  27.  
  28.       int num, digit;
  29.  
  30.       cout << "\nEnter a 3 digit integer:";
  31.  
  32.       cin >> num;                          // Step A
  33.  
  34.       cout << "\nThe number in reversed order is: ";
  35.  
  36.  
  37.  
  38.       digit = num%10;                      // Step B
  39.  
  40.       num = num/10;
  41.  
  42.       cout << digit;
  43.  
  44.  
  45.  
  46.       digit = num%10;                      // Step C
  47.  
  48.       num = num/10;
  49.  
  50.       cout << digit;
  51.  
  52.  
  53.  
  54.       digit = num%10;                      // Step D
  55.  
  56.       num = num/10;
  57.  
  58.       cout << digit;
  59.  
  60.  
  61.  
  62.       cout << endl;
  63.       system ("PAUSE");
  64.       return 0;
  65.  
  66. }
  67.  



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
Sep 13 '07 #1
7 2191
sicarie
4,677 Expert Mod 4TB
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....)
Sep 13 '07 #2
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
Sep 13 '07 #3
sicarie
4,677 Expert Mod 4TB
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?
Sep 13 '07 #4
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
Sep 13 '07 #5
sicarie
4,677 Expert Mod 4TB
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?
Sep 13 '07 #6
Savage
1,764 Expert 1GB
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

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. STEP        DIGIT        NUM
  4. --------------------------------------
  5.  A           123         123
  6.  B             3          12
  7.  -
  8.  -
  9.  
  •  

  • something like that?
    Sep 13 '07 #7
    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;
    Sep 13 '07 #8

    Sign in to post your reply or Sign up for a free account.

    Similar topics

    2
    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,...
    2
    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...
    4
    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...
    3
    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...
    8
    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...
    130
    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...
    2
    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...
    5
    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...
    1
    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...
    0
    by: Charles Arthur | last post by:
    How do i turn on java script on a villaon, callus and itel keypad mobile phone
    0
    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
    0
    BarryA
    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...
    1
    by: nemocccc | last post by:
    hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
    1
    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...
    0
    marktang
    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,...
    0
    Oralloy
    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,...
    0
    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...
    0
    agi2029
    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,...

    By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

    To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.