I need help with a program

P

Pixie

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;
}
 
H

Howard

Pixie said:
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
 
A

Alf P. Steinbach

* Pixie:
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.
 
P

Pixie

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.
 
M

Mike Wahler

Pixie said:
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.
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
 
P

Pixie

Thank u. I should rephrase this question and put my ideas on how to do
the code. Thank you.
 
O

osmium

Pixie said:
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++).
 

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,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top