I am using "C++ how to program" by deitel/deitel forth edition. The problem is as follows:
"Write a program that inputs a five-digit number, spearates the number into its individual digits and prints the digits separated from one another by three spaces each. (Hint: use the integer division and modulus operators)."
It's in chapter 1, so the only things I have learned so far is the basics: cout, cin, cerr, mathmatic operators (order of operations) and if statements. Here is my code:
Code:01 #include <iostream> 02 03 int main() 04 { 05 int 5digitnumber; 06 int newoutput; 07 08 std::cout <<"Input a 5 digit number"<<std::endl; 09 std::cin >>5digitnumber <<std::endl; 10 11 newoutput = 5digitnumber / 1; //trying to separate digits...im so lost here. 12 13 std::cout <<newoutput; 14 return 0; 15 }![]()



LinkBack URL
About LinkBacks




