Connecting Tech Pros Worldwide Help | Site Map

Help!

 
LinkBack Thread Tools Search this Thread
  #1  
Old October 11th, 2005, 12:45 AM
coinjo
Guest
 
Posts: n/a
Default Help!

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, 01:15 AM
Victor Bazarov
Guest
 
Posts: n/a
Default 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, 01:45 AM
coinjo
Guest
 
Posts: n/a
Default 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, 02:25 AM
coinjo
Guest
 
Posts: n/a
Default 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, 04:05 AM
cpluspluskilla@gmail.com
Guest
 
Posts: n/a
Default Re: Help! Andrej Y. Hristeoliubov will help you with homeworks.


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, 05:26 AM
GB
Guest
 
Posts: n/a
Default 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, 07:55 AM
Karl Heinz Buchegger
Guest
 
Posts: n/a
Default 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, 04:25 PM
Default User
Guest
 
Posts: n/a
Default 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.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

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 220,989 network members.