Another C++ programming question.
I have recently found an AWESOME home/type study course called "The Complete C++ Training Course" and I am totally loving it, as it is by far the best I have seen amoung the combination of home study and beginners guides.... The question I have is because of the following:
At the end of every chapter, there are (what you might expect) exercises to prove that you really paid attention in the reading. They are not as easy (at least so far as I have noticed), as the ones in other books. I am having trouble with the 36th exercise, because I am not totally sure that The question covers something I have learned in that chapter... In all actuallity, the book has yet to go in depth on anything related to C++ language itself (read the syntax), but instead, has covered more about WHAT it is and where it came from, and what OOP and OOD (along with what UML) are.. The reason I am asking this, is because it doesnt have the answers to the questions in the exercises, as they are used in colleges and the like.... The exercise question is this: Quote:
|
http://people.uncw.edu/tompkinsj/112...36solution.cpp
// Exercise 1.36 Solution #include <iostream> using std::cout; using std::endl; using std::cin; int main() { int num; cout << "Enter a five-digit number: "; cin >> num; cout << num / 10000 << " "; //prints the left most digit (5th) num = num % 10000; //assigns a new value to num -four digits cout << num / 1000 << " "; //prints the left most digit (4th) num = num % 1000; //assigns a new value to num -three digits cout << num / 100 << " "; //prints the left most digit (3rd) num = num % 100; //assigns a new value to num -two digits cout << num / 10 << " "; //prints the left most digit (2nd) num = num % 10; //assigns a new value to num -one digit cout << num << endl; //prints the last digit of num and a newline return 0; } |
Sweet, thank you very much... That was the ONLY one in the exercises that I had any problem with...
|
All times are GMT -4. The time now is 10:23 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.