Showing posts with label multiplication table. Show all posts
Showing posts with label multiplication table. Show all posts

Friday, July 25, 2014

Multiplication Table

In order for us to improve our programming skills we must always practice and solve different programming problems that we encounter in our day to day life. One of the most interesting problem that I encounter when I started write a program is how to create a multiplication table using C++ programming language as my primary language. Maybe some people think my problem is very easy and very basic but for me even a simple problem has a place for me in improving my skills and understanding how to create good algorithm to derive a solution to the problem.

I started using nested for loop statement to generate the multiplication values by multiplying the values of variable x and y. I also use the C++ library called iomanip or its stands for input and output manipulator to give spacing of values in our program. The code is very short and very easy to understand I intended my work for beginners in C++ programming I hope they will find my work useful.

If you have some questions about my works feel free to send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.

Thank you very much.


Sample Output of Our Program


Zip File Content of Our Program

Program Listing

#include <iostream>
#include <iomanip>

using namespace std;

main()
{
    cout << "\t    Multiplication Table";
    cout << "\n\n";
    for (int x=1; x!=11; x=x+1) {
            cout << "\n";
            for (int y=1; y<=10; y++) {
        cout << setw(4) << x*y;
            }
    }
 cout << "\n\n";
}



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");
}