Help! 
October 11th, 2005, 01:45 AM
| | | |
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; | 
October 11th, 2005, 02:15 AM
| | | | 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 | 
October 11th, 2005, 02:45 AM
| | | | 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! | 
October 11th, 2005, 03:25 AM
| | | | 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! | 
October 11th, 2005, 05:05 AM
| | | | 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 | 
October 11th, 2005, 06:26 AM
| | | | 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 | 
October 11th, 2005, 08:55 AM
| | | | 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 | 
October 11th, 2005, 05:25 PM
| | | | 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. |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,698 network members.
|