C++ Nested For

//lh3.googleusercontent.com/-K5UKWzgJhmU/AAAAAAAAAAI/AAAAAAAACdI/CN3nwiBZsGE/s512-c/photo.jpg
November 27, 2016




anda pasti sudah mengerti dengan tampilan di samping, jadi katika anda menginput nilai 10 maka outputnya menampilkan 10 baris ke bawan dan kesamping. selamat mencoba.


#include <iostream>

using namespace std;

main()
{
    int x=2, z=0;
    cout<<"input number = ";
    cin>>x;
    for (int a=1; a<=x; a++)
        {
            for (int b=1;b<=a;b++)
            {
                cout<<b;
            }
            cout<<endl;

        }


}


Related Post

SUBSCRIBE TO OUR NEWSLETTER

closed