Counting Page Numbers

This is a discussion on Counting Page Numbers within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream.h> #include "apvector.h" int main() { apvector <int>num(6,0 ); apvector <int>page(6,0 ); apvector <int>temp(6,0 ); int cnt=0, len=0, ...

  1. #1
    eat my shorts!
    Join Date
    Apr 2002
    Posts
    294

    Question Counting Page Numbers

    Code:
    #include <iostream.h>
    #include "apvector.h"
    
    int main()
    {
    	
    	apvector <int>num(6,0 );
    	apvector <int>page(6,0 );
    	apvector <int>temp(6,0 );
    	int cnt=0, len=0, x, p=0;
    	
    	for (x=0; x<6; x++)
    	{
    		len = 0;
    		cout << "\nEnter page Number:";
    		cin >> num[x];
    		if (num[x] < 0)
    			break;
    		do {
    		
    			num[x] = num[x]/10;
    			len++;
    			
    		} while (num[x] > 0);
    		temp[x] = len;
    		cnt++;
    	}	
    
    }
    The program is suppose to output:
    123
    136
    139
    1001
    1021
    1100

    if the user enter numbers:
    123
    36
    9
    1001
    1021
    1100

    The above code is incomplete: cant figure a way of adding em.


    AP CLASS folder has been included
    Attached Files Attached Files
    Last edited by dayknight; 11-09-2002 at 05:04 PM.

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    the simple answer is there is no call to cout except to ask user for input. Therefore it can never output anything but that statement.

    However, a more significant problem is that the goal of the program is also unclear. Therefore I (and any other potential assistants) don't know how to help. Please be more descriptive if you can.

  3. #3
    eat my shorts!
    Join Date
    Apr 2002
    Posts
    294
    the object of the code is to output page numbers
    lets say: if some user enter page numbers:

    123
    36
    9
    1001
    1021
    1100

    The program is going to output numbers:
    123
    136
    139
    1001
    1021
    1100

    For example: the first 2 numbers that user enters are 123 and 36
    the program is going to make 123 to 100 and add 36 to 100 making the result 136, likewise if the user enters page number 9 and 1001 , the program is going to output 1001 since 1001 is a bigger number than 9 and comes after it (ie. the user entered it after he entered 9).

    i hope this helps

    and yes the code is incomplete; thats y i didnt cout anything yet.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Page File counter and Private Bytes Counter
    By George2 in forum Tech Board
    Replies: 0
    Last Post: 01-31-2008, 03:17 AM
  2. virtual memory
    By sweets in forum C Programming
    Replies: 6
    Last Post: 11-06-2004, 06:55 AM
  3. Program that prints numbers in columns
    By rayrayj52 in forum C++ Programming
    Replies: 12
    Last Post: 09-20-2004, 03:43 PM
  4. Adding Line numbers in Word
    By Mister C in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 06-24-2004, 09:45 PM
  5. Homework help
    By Jigsaw in forum C++ Programming
    Replies: 2
    Last Post: 03-06-2002, 05:56 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21