C++ Using Iomanip & Setw (CUIS)


CUIS:    SOLD




Here I will share a C++ programming demo using the preprocessor #include<iomanip.h> for the setw() function which is usually implemented on a matrix, just go ahead and see the full discussion below:


C++ Iomanip & Setw

Source code:

#include <iostream.h>
#include <conio.h>
#include <iomanip.h>

/**
*bundet.com
*IOMANIP & SETW
*/

void main() {

    int k;

    for (int i = 0; i < 10; i++) {
        k = i * 100 + 1;

        for (int j = k; j < k + 100; j++) {
            cout << "   " << setw(4) << j;

            if ( j % 10 == 0 ){
                cout << endl;
            }
        }
        cout << "Tekan ENTER untuk melanjutkan..." << endl;
        getch();
    }

    getch();
}

Hope this is useful and happy learning

Comment 1

  1. FAHRY FREAK 22 Jun 2015, 12:05:00 = What is the function of setw, bro?
  2. ABADILLAH WIDODO 6 Oct 2015, 19:50:00 = thank you, bro, the setw program is really helpful.

Response 1

  1. To provide space on the output to be printed. To better understand how the process works, please just modify the numbers in setw(4) above, and observe the changes... that's it bro.. happy learning..
  2. Hii Abillah W... you're welcome, good luck

Post a Comment

Previous Next

نموذج الاتصال