So, this is for a school project. I am attempting to create a program that counts from 00 - 77 in octal. I was given a base code, and told to modify it. So far, this is what I have, but my code is starting at 07 instead of 00. Any help would be appreciated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
usingnamespace std;
int main()
{
for (int i = 0; i < 8; i++)
for (int j = i; j < 8; j++)
cout << i << j << "\n";
system("pause");
return 0;
}
What are you talking about? You code does start from 00.
It does not show all numbers in the range.
Please, explain the line 7 for us.
Could you also explain any of this:
1 2 3 4 5 6 7 8 9 10
#include <iostream>
#include <iomanip>
int main() {
std::cout.fill( '0' );
std::cout << std::oct;
for ( int value = 0; value < 0100; ++value ) {
std::cout << std::setw( 2 ) << value << '\n';
}
}
(While it might give desired output, this code is not what you must write.)
EDIT
my code is starting at 07
...
now it starts at 43.
Let me guess: You look at last N lines of the output of the program. Either your terminal does not let you scroll back (enough), or you did not realize that you can do so.
I apologize, I am very new to c++. This is my assignment as given from my instructor:
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
usingnamespace std;
int main()
{
for(int i = 0; i < 2; i++)
for(int j = 0; j < 2; j++)
for(int k = 0; k < 2; k++)
cout << i << j << k << "\n";
system("pause");
return 0;
}
"Type the program above in and run it. This program counts from 000 to 111 in Binary (0 – 7 Decimal) using only digits 0 – 1. A related numbering system is Octal, and uses the digits 0 – 7. Modify the program above to count from 00 to 77 in Octal (0 – 63 Decimal). Hint: You will only need 2 for loops instead of 3."