Answers for "1. Print multiplication table using loop in c++"

C++
0

multiplication table c++ for loop

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main()
{
	cout << " X"; 
	for (int q = 1 ; q<=10 ; q++)
	{
		cout << setw(4) << q ; 
	}
	
	cout<< "\n";
	
	for (int i = 1 ; i<=10 ; i++)
	{
		cout << setw(2) << i; 
		for (int j = 1; j<= 10 ; j++)
		{
			cout << setw(4) << j*i; 
		}
		
		cout << "\n";
	}
}
Posted by: Guest on October-21-2021
0

1. Print multiplication table using loop in c++

#include <iostream>
using namespace std;

int main() {

    //#ifndef ONLINE_JUDGE // not part of code, used to beautify input output
    //    freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
    //#endif

    int num;
    cin >> num;

    for (int i = 1; i <= 10; i++) {
        cout << num << " * " << i << " = " << num * i << endl;
    }

    return 0;
}
Posted by: Guest on October-25-2021
0

1. Print multiplication table using loop in c++

#include <iostream>
using namespace std;

int main() {

    //#ifndef ONLINE_JUDGE // not part of code, used to beautify input output
    //    freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
    //#endif

    int num;
    cin >> num;

    for (int i = 1; i <= 10; i++) {
        cout << num << " * " << i << " = " << num * i << endl;
    }

    return 0;
}
Posted by: Guest on October-25-2021

Code answers related to "1. Print multiplication table using loop in c++"

Browse Popular Code Answers by Language