for di c++

#include <iostream>
using namespace std;
main(){
    cout <<"\n   PROGRAM BANGUN DATAR";
    cout <<"\n============================";
    cout <<endl<<endl;

    int pilih,p,l,n;
    cout <<"\n1.PERSEGI PANJANG";
    cout <<"\n2.SEGITIGA";
    cout <<"\nPILIH(1-2):";cin>>pilih;
    if (pilih==1){
        cout<<"\n   PERSEGI PANJANG";
        cout <<"\n=====================";
        cout<<"\nMASUKAN LEBAR:";cin>>p;
        cout<<"\nMASUKAN PANJANG:";cin>>l;
            cout<<endl;
            for(int j=1; j<=p; j++){
            for(int i = 1; i<=l; i++){
            cout << "=";
                }
            cout << endl;
                }
                }
        else if (pilih==2){
            cout<<"\n   SEGITIGA";
            cout <<"\n=============";
            cout << "\nMASUKAN UKURAN(1-10):";cin>>n;
            cout<<endl;
            for(int a = 1; a<=n; a++){
            for(int b=a; b<=n; b++){
            cout <<" ";
            }
            for(int c=1; c<=2*a-1; c++){
            cout << "+";
            }
            cout<<endl;
            }
            }
            else{
                cout <<"\nKELUAR";
            }
}

Komentar