Connecting Tech Pros Worldwide Help | Site Map

Help!

  #1  
Old October 11th, 2005, 01:45 AM
coinjo
Guest
 
Posts: n/a
I need to write a program, which takes any number of digits, and
combine them in the form of one integer value.

User will enter the digits one by one. The number of the digits to be
entered by the user is not known. The initial structure of the program
is written below. User enters -1 as an end marker.

int Digit=0;
int Var1=0;


cout<<"Enter a digit. Enter -1 to stop"<<endl;

while (Digit!=-1)
{
cin>>Digit;

/Write syntax here to combine the digits to form an
integer/
}

cout<<"The value is"<<endl;
cout<<Var1;

  #2  
Old October 11th, 2005, 02:15 AM
Victor Bazarov
Guest
 
Posts: n/a

re: Help!


coinjo wrote:[color=blue]
> I need to write a program, which takes any number of digits, and
> combine them in the form of one integer value.
>
> User will enter the digits one by one. The number of the digits to be
> entered by the user is not known. The initial structure of the
> program is written below. User enters -1 as an end marker.
>
> int Digit=0;
> int Var1=0;
>
>
> cout<<"Enter a digit. Enter -1 to stop"<<endl;
>
> while (Digit!=-1)
> {
> cin>>Digit;
>
> /Write syntax here to combine the digits to form an
> integer/
> }
>
> cout<<"The value is"<<endl;
> cout<<Var1;[/color]


That's a good start. Now, every C++ program must have 'main' function.
Wrap that code in a function, call it 'main', no arguments, return type
'int', then add necessary headers and you will have the program you can
compile and run. After that, add functionality.

V


  #3  
Old October 11th, 2005, 02:45 AM
coinjo
Guest
 
Posts: n/a

re: Help!


I am able to write the program in the correct the syntax but the
functionality of this program is the main problem for me. Please Help!
Give me some clues about the functionality of this program!

  #4  
Old October 11th, 2005, 03:25 AM
coinjo
Guest
 
Posts: n/a

re: Help!


I am able to write the program in the correct the syntax but the
functionality of this program is the main problem for me. Please Help!
Give me some clues about the functionality of this program!

  #5  
Old October 11th, 2005, 05:05 AM
cpluspluskilla@gmail.com
Guest
 
Posts: n/a

re: Help!



coinjo wrote:[color=blue]
> I am able to write the program in the correct the syntax but the
> functionality of this program is the main problem for me. Please Help!
> Give me some clues about the functionality of this program![/color]


I am currently unemployed and willing to do your assignment. I
guarantee an A+++ or money back. Speaking of money - I charge $90 per
hour. Email me if you find my offer to interest you. Also, if any of
your peers in high school have difficulties with such rudimentary
assignments, forward this offer to them as well.


Andrej Y. Hristoliubov

  #6  
Old October 11th, 2005, 06:26 AM
GB
Guest
 
Posts: n/a

re: Help!


coinjo wrote:[color=blue]
> I am able to write the program in the correct the syntax but the
> functionality of this program is the main problem for me. Please Help!
> Give me some clues about the functionality of this program!
>[/color]

Hint:

Store the value in an int variable. Accept the user's digits in a loop,
and each time through the loop update the int variable based on the
digit just entered.

If the user has provided the digits '2', '4', and '6' so far, you will
have somehow converted that so that it is stored in your internal int
variable with value 246. Then the user enters a new digit, say '8'. What
do you have to do to the int variable to append the new digit?

Gregg
  #7  
Old October 11th, 2005, 08:55 AM
Karl Heinz Buchegger
Guest
 
Posts: n/a

re: Help!


coinjo wrote:[color=blue]
>
> I am able to write the program in the correct the syntax but the
> functionality of this program is the main problem for me. Please Help!
> Give me some clues about the functionality of this program![/color]

Watch this:

0

now the user enters '1'

10 * 0 + 1 -> 0 + 1 -> 1

now the user enteres '5'

10 * 1 + 5 -> 10 + 5 -> 15

the user enters '8'

10 * 15 + 8 -> 150 + 8 -> 158

the user enters '3'

10 * 158 + 3 -> 1580 + 3 -> 1583

Is that hint enough?

--
Karl Heinz Buchegger
kbuchegg@gascad.at
  #8  
Old October 11th, 2005, 05:25 PM
Default User
Guest
 
Posts: n/a

re: Help!


coinjo wrote:
[color=blue]
> I am able to write the program in the correct the syntax but the
> functionality of this program is the main problem for me. Please Help!
> Give me some clues about the functionality of this program![/color]

Some reason why you want to keep that code a secret from us?



Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET IDR_MAINFRAME menu problem - application Help menu conflict with Excel Help menu hitencontractor answers 0 August 2nd, 2008 01:35 PM
Where is the help? Mark answers 8 September 26th, 2006 07:55 PM
Missing Help Files Corepaul answers 7 November 13th, 2005 02:51 AM
help me? About "include files" wukexin answers 6 July 22nd, 2005 06:46 AM
Saved .rtf Help File corrupt after reformatting system Dave answers 21 July 17th, 2005 10:25 PM