What's new

C & C++ Matrix output C++

kevong123

Leecher
Pa help naman po. gusto ko po sana syang ma print in matrix 10x10, using nested loop.
PS function sya.


1653902793912.png


Parang ganto po.
1653903056526.png
 

Attachments

Last edited:
Solution
Ahh yeah oo nga, sorry bakit nga ba hardcoded yung sa modulus haha
Eto variable na yung sa modulus part, paki check sa ibang numbers

C++:
#include <iostream>
using namespace std;

int main()
{
    int num, i;
    cout << "\n\n";
    cout << "====================== MULTIPLES OF A NUMBER ======================";
    cout << endl << "Input a number: ";
    cin >> num;
    cout << "\t\tThese are the first 100 multiples of " << num <<endl;

    for (int i = 1; i <= 100; i++)
    {
        cout << i * num << "\t";
        if ((i * num) % (num*10) == 0)
        {
            cout << endl;
        }
    }
    getchar();
}
Gumagana yung code mo dinagdagan ko lang, "modulus" yata yun tawag dun

C++:
#include <iostream>
using namespace std;

int main()
{
    int num, i;
    cout << "\n\n";
    cout << "====================== MULTIPLES OF A NUMBER ======================";
    cout << endl << "Input a number: ";
    cin >> num;
    cout << "\t\tThese are the first 100 multiples of " << num <<endl;

    for (int i = 1; i <= 100; i++)
    {
        cout << i * num << "\t";
        if ((i * num) % 20 == 0)
        {
            cout << endl;
        }
    }
    getchar();
}
 
Gumagana yung code mo dinagdagan ko lang, "modulus" yata yun tawag dun

C++:
#include <iostream>
using namespace std;

int main()
{
    int num, i;
    cout << "\n\n";
    cout << "====================== MULTIPLES OF A NUMBER ======================";
    cout << endl << "Input a number: ";
    cin >> num;
    cout << "\t\tThese are the first 100 multiples of " << num <<endl;

    for (int i = 1; i <= 100; i++)
    {
        cout << i * num << "\t";
        if ((i * num) % 20 == 0)
        {
            cout << endl;
        }
    }
    getchar();
}
Yung gusto sana ng prof namin 10x10 lahat ng output. pag nag insert ako ng ibang number ibang layout ulit sya.

ang sabi gamitan daw ng nested loop. btw thanks sa effort
 
Last edited:
Ahh yeah oo nga, sorry bakit nga ba hardcoded yung sa modulus haha
Eto variable na yung sa modulus part, paki check sa ibang numbers

C++:
#include <iostream>
using namespace std;

int main()
{
    int num, i;
    cout << "\n\n";
    cout << "====================== MULTIPLES OF A NUMBER ======================";
    cout << endl << "Input a number: ";
    cin >> num;
    cout << "\t\tThese are the first 100 multiples of " << num <<endl;

    for (int i = 1; i <= 100; i++)
    {
        cout << i * num << "\t";
        if ((i * num) % (num*10) == 0)
        {
            cout << endl;
        }
    }
    getchar();
}
 
Solution

Similar threads

Back
Top