Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Source 

Print Multiplication Table (C++)

Code
#include <iostream>
#include <stdlib.h>
using namespace std;

void Clear()
{
#if defined _WIN32
    system("cls");
#elif defined (__LINUX__) || defined(__gnu_linux__) || defined(__linux__) || defined (__APPLE__)
    system("clear");
#endif
}

int main()
{
    int j, i, n;

    cout << "\n Input the number upto 10: ";
    cin >> n;
    Clear();
    cout << "\nMultiplication table from 1 to " << n << endl;
    ;
    cout << "--------------------------------------------------------------------------------\n";



    for (i = 1; i <= 10; i++)
    {
        for (j = 1; j <= n; j++)
        {
            if (j <= n - 1)
                cout << j << "x" << i << "=" << i * j << " ";
            else
                cout << j << "x" << i << "=" << i * j << " ";
        }
        cout << endl;

    }

    cout << '\n' << '\n';
    system("pause");

    cout << "\n\nPress the enter key to exit";



    return 0;
}


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Source] by Emre_Apr 21, 2024 11:07 AM 0 99 Apr 21, 2024 11:07 AM
Last Post: Emre_
by X-LITDec 13, 2022 06:33 AM 4 149 Dec 13, 2022 06:33 AM
Last Post: Hackers
[Help] by Grey GooseFeb 15, 2019 09:39 AM 3 168 Feb 15, 2019 09:39 AM
Last Post: Abruptum