🔒 Closed Matrix output C++

Status
Not open for further replies.

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
 
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
 
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
Status
Not open for further replies.

About this Thread

  • 3
    Replies
  • 679
    Views
  • 2
    Participants
Last reply from:
Aoshinomori

Online now

Members online
1,011
Guests online
711
Total visitors
1,722

Forum statistics

Threads
2,275,600
Posts
28,964,376
Members
1,231,881
Latest member
kakakoko
Back
Top