🔒 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
  • 693
    Views
  • 2
    Participants
Last reply from:
Aoshinomori

Trending Topics

Online now

Members online
538
Guests online
1,432
Total visitors
1,970

Forum statistics

Threads
2,286,439
Posts
29,037,765
Members
1,217,951
Latest member
lolpops
Back
Top