| View previous topic :: View next topic |
| Author |
Message |
Pixie Guest
|
Posted: Thu Sep 29, 2005 3:09 pm Post subject: I need help with a program |
|
|
I was asked by professor to figure out the mistakes and fill in the
functions for this program. I cannot figure it out and I hope someone
can help me.Any input would be helpful. Thanks, PIXIE
here is the program:
// digits.cpp
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
int num;
cout << "Enter a five-digit number: ";
cin >> num;
/* write a statement to print the left-most digit of 5-digit number
*/
/* write a statement that changes num from a 5-digits to 4-digits
*/
/* write a statement to print the left-most digit of 4-digit number
*/
/* write a statement that changes num from a 4-digits to 3-digits
*/
/* write a statement to print the left-most digit of 3-digit number
*/
/* write a statement that changes num from a 3-digits to 2-digits
*/
/* write a statement to print the left-most digit of 2-digit number
*/
/* write a statement that changes num from a 2-digits to 1-digit
*/
cout << num << endl;
return 0;
}
|
|
| Back to top |
|
 |
Howard Guest
|
Posted: Thu Sep 29, 2005 3:19 pm Post subject: Re: I need help with a program |
|
|
"Pixie" <APEXA.GANDHI (AT) gmail (DOT) com> wrote
| Quote: | I was asked by professor to figure out the mistakes and fill in the
functions for this program. I cannot figure it out and I hope someone
can help me.Any input would be helpful.
|
Geez, you could at least make SOME effort at doing your own homework!
-Howard
|
|
| Back to top |
|
 |
Alf P. Steinbach Guest
|
Posted: Thu Sep 29, 2005 3:21 pm Post subject: Re: I need help with a program |
|
|
* Pixie:
| Quote: | I was asked by professor to figure out the mistakes and fill in the
functions for this program. I cannot figure it out and I hope someone
can help me.Any input would be helpful. Thanks, PIXIE
here is the program:
// digits.cpp
#include <iostream
using std::cout;
using std::cin;
using std::endl;
int main()
{
int num;
cout << "Enter a five-digit number: ";
cin >> num;
/* write a statement to print the left-most digit of 5-digit number
*/
|
Instead of what your professor suggests, try
// write a statement to print the RIGHT-MOST digit of 'num'.
And similarly for the rest.
After you've done that you'll be in a better position to do the prof's
assignment.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
|
|
| Back to top |
|
 |
Pixie Guest
|
Posted: Thu Sep 29, 2005 3:29 pm Post subject: Re: I need help with a program |
|
|
I did try to do this program, and I could not figure it out and that is
why I asked for help. I did not ask anyone to do the program for me, I
only asked for input.
|
|
| Back to top |
|
 |
Mike Wahler Guest
|
Posted: Thu Sep 29, 2005 3:31 pm Post subject: Re: I need help with a program |
|
|
"Pixie" <APEXA.GANDHI (AT) gmail (DOT) com> wrote
| Quote: | I did try to do this program,
|
If you did try, then you have some code. If you want
help with it, post it and ask specific questions. If
you do that, you'll get plenty of help.
| Quote: | and I could not figure it out and that is
why I asked for help. I did not ask anyone to do the program for me, I
only asked for input.
|
We can't give input on what we can't see.
Post your code.
-Mike
|
|
| Back to top |
|
 |
Pixie Guest
|
Posted: Thu Sep 29, 2005 3:37 pm Post subject: Re: I need help with a program |
|
|
Thank u. I should rephrase this question and put my ideas on how to do
the code. Thank you.
|
|
| Back to top |
|
 |
osmium Guest
|
Posted: Thu Sep 29, 2005 3:40 pm Post subject: Re: I need help with a program |
|
|
"Pixie" writes:
| Quote: | I was asked by professor to figure out the mistakes and fill in the
functions for this program. I cannot figure it out and I hope someone
can help me.Any input would be helpful. Thanks, PIXIE
here is the program:
// digits.cpp
#include <iostream
using std::cout;
using std::cin;
using std::endl;
int main()
{
int num;
cout << "Enter a five-digit number: ";
cin >> num;
/* write a statement to print the left-most digit of 5-digit number
*/
/* write a statement that changes num from a 5-digits to 4-digits
*/
/* write a statement to print the left-most digit of 4-digit number
*/
/* write a statement that changes num from a 4-digits to 3-digits
*/
/* write a statement to print the left-most digit of 3-digit number
*/
/* write a statement that changes num from a 3-digits to 2-digits
*/
/* write a statement to print the left-most digit of 2-digit number
*/
/* write a statement that changes num from a 2-digits to 1-digit
*/
cout << num << endl;
return 0;
}
|
See what kinds of wonderful things you can do with the modulo operator
(which is '%' in C++).
|
|
| Back to top |
|
 |
|