Thursday, June 5, 2014

Multiplication Table Creator

One of my favorite programming language to write a program and play around in C++ programming language it is a very versatile programming language you can write different kinds of applications from systems application to business applications. What I learned in C++ give me confidence to learn much easier other programming language like C#,Java and PHP because there any many similarities in these programming languages is also based in C++.

In this article I will show you how to create a multiplication table creator in C++. This program will ask the user to enter first the row value and then the column value and our program will generate the multiplication table on our screen. Actually the program is very simple and easy to understand the code is very short. I wrote a function to generate the multiplication I called the function mul_table. The logic of our program is the use of nested for loop statement, I also used setw statement that can be found in the use of a C++ library file called #include <iomanip> it is mean input and output manipulator used primarily for text formatting in C++.


int mul_table(int row, int column)
 {
  cout << "\n\n";
  cout << "\t  MULTIPLICATION TABLE";
  cout << "\n\n";
  for (int x=1; x<=row; x++) {
         cout << "\n";
        for (int y=1; y<=column; y++) {
         cout << setw(5) << x * y;

        }
    }
 }

I hope you will find my work useful thank you very much.



Sample Output of Our Program


Code::Blocks text editor that I used in writing this program


Program Listing

// multiplication table creator
// Written by: Mr Jake R. Pomperada, MAED-IT
// Tools : Code:Blocks and Dev C++
// June 5, 2014 Thursday


#include <iostream>
#include <iomanip>

 using namespace std;

int mul_table(int row, int column);


 int mul_table(int row, int column)
 {
  cout << "\n\n";
  cout << "\t  MULTIPLICATION TABLE";
  cout << "\n\n";
  for (int x=1; x<=row; x++) {
         cout << "\n";
        for (int y=1; y<=column; y++) {
         cout << setw(5) << x * y;

        }
    }
 }

main() {
    int numbers[2];
    cout << "\t Multiplication Table Creator ";
    cout << "\n\n";
    cout << "Enter Row Number    :=> ";
    cin >> numbers[0];
    cout << "Enter Column Number :=> ";
    cin >> numbers[1];
    mul_table(numbers[0], numbers[1]);
    cout << "\n\n";
    system("pause");
}






No comments:

Post a Comment