Connecting Tech Pros Worldwide Help | Site Map

Help!

coinjo
Guest
 
Posts: n/a
#1: Oct 11 '05
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;

Victor Bazarov
Guest
 
Posts: n/a
#2: Oct 11 '05

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


coinjo
Guest
 
Posts: n/a
#3: Oct 11 '05

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!

coinjo
Guest
 
Posts: n/a
#4: Oct 11 '05

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!

cpluspluskilla@gmail.com
Guest
 
Posts: n/a
#5: Oct 11 '05

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

GB
Guest
 
Posts: n/a
#6: Oct 11 '05

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
Karl Heinz Buchegger
Guest
 
Posts: n/a
#7: Oct 11 '05

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
Default User
Guest
 
Posts: n/a
#8: Oct 11 '05

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