What's new

[Release] Multiplaction Tables in C++

  • Thread starter Trammell
  • Start date
  • Views 665
Trammell

Trammell

Retired
Retired
Reporter Forum Addict
Messages
3,408
Reaction score
2,701
c5d606c4.png


Dat Multiplyin Table


Code:
#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
//display the column headings
int nColumn = 0;
cout << "  ";
while (nColumn < 10)
{
//set display width to two characters
// (even for one digit numbers)
cout.width(2);

//now display the column number
cout << nColumn << " ";

//increment to the next column
nColumn++;
}
cout << endl;

// now go loop through the rows
int nRow = 0;
while (nRow < 10)
{
//start with row value
cout << nRow << " - ";

//now for each row start with column 0 and
//go through column 9
nColumn = 0;
while (nColumn < 10)
{
//display the product of the column*row
// Use 2 characters even when product is
//a single digit
cout.width(2);
cout << nRow * nColumn << "  ";

// go to next column
nColumn++;
}
// go to next row
nRow++;
cout << endl;
}
}


I can haz Programmmmmerr Award
 
ZMOT

ZMOT

Steve Harvey
AzzidReign Jr Fabled Veteran Hardened Veteran
Messages
3,253
Reaction score
1,368
Your not supposed to be here anymore! :tongue:


OT: Looks simple, but it works...
 
Top Bottom