Help!

C

coinjo

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;
 
V

Victor Bazarov

coinjo said:
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;


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
 
C

coinjo

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!
 
C

coinjo

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!
 
C

cpluspluskilla

coinjo said:
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!


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
 
G

GB

coinjo said:
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!

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
 
K

Karl Heinz Buchegger

coinjo said:
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!

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?
 
D

Default User

coinjo said:
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!

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



Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top