Question

I am doing a table with 3 columns Dec Okt Hex in C++.

The input should be an integer, greater than or equal to 1, then print a table with three columns, where all the integers from 1 to the loaded number specified in decimal, octal and hexadecimal.

For example we input number 16 the output should be like this:

and here is my code:

#include <cstdlib>
#include <iostream>

using namespace std;

int main ()
{
    
    
   while ( 1)
    {
        int varde ;
        cout << " Give the desired value (at least 1 ):";
        cin >> varde ;
        
        if ( varde <1 )
         {
           cout << varde << "Invalid value , try again! Give the desired value for the table :";
         }
         
         else
         {
             cout << " desired value " << varde << "\ n";

         }
         
      
        
          

          for (int row = 0; row < varde ; + + row )
               {
                       for (int column = 0; columnIndex < 3; + + column )
                            {
                                std :: cout << std :: December << varde << '\ t ';
                                std :: cout << std :: hex << varde << '\ t ';
                                std :: cout << std :: oct << varde << '\ t ';
                                
 
                            }
                       std :: cout << std :: endl;
    
                }
         
         
         
         
          
     }
     
 }

but I got this output:

https://s27.postimg.org/mj8kzppnn/up2_2.jpg

Was it helpful?

Solution

You want to output row, the variable you're iterating over, not varde, the desired maximum value, right?

std :: cout << std :: dec << row << '\ t ';
std :: cout << std :: hex << row << '\ t ';
std :: cout << std :: oct << row << '\ t ';
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top