program bentuk huruf x

Program Bentuk Huruf X

programnya seperti ini

huruf x

dalam membuat program ini, anda setidaknya harus mengeri tentang pegulangan pada c++. program ini saya buat dari pengulangan for. langsung saja simak silahkan mencoba membuat program bentuk huruf x.

 

//program simbol x

#include<iostream>

using namespace std;

 

int main()

{

for(int i=0; i<6; i++)

{

for(int j=0;j<i;j++)

{

cout<<” “;

}

cout<<“*”;

for(int a=4; a>=i; a–)

{

for(int b=2; b>0; b–)

{

cout<<” “;

}

}

cout<<“*”;

cout<<endl;

}

 

 

for(int i=5; i>=0; i–)

{

for(int j=0;j<i;j++)

{

cout<<” “;

}

cout<<“*”;

for(int a=4; a>=i; a–)

{

for(int b=2; b>0; b–)

{

cout<<” “;

}

}

cout<<“*”;

cout<<endl;

}

cin.get();

return 0;

}

Thanks.

 

Leave a comment