16
Latihan 4 Looping Nama :Rheza Ariyanto Kelas :TKJ 1B

Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include #include using namespace std; main { int p, q, r; p=5;

Embed Size (px)

Citation preview

Page 1: Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include  #include  using namespace std; main { int p, q, r; p=5;

Latihan 4 Looping

Nama :Rheza Ariyanto

Kelas :TKJ 1B

Page 2: Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include  #include  using namespace std; main { int p, q, r; p=5;

Latihan Soal 1.A

Page 3: Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include  #include  using namespace std; main { int p, q, r; p=5;
Page 4: Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include  #include  using namespace std; main { int p, q, r; p=5;
Page 5: Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include  #include  using namespace std; main { int p, q, r; p=5;

Bahasa C++

#include <iostream>

#include <iomanip.h>

using namespace std;

main ()

{

int p, q, r;

p=5;

cout<<"Latihan Soal 1.a\n\n";

for (q=p; q>=2; q--)

{

cout<<setw(q);

for (r=q; r<=p; r++)

{

cout<<"*";

}

for (r=q+1; r<=p; r++)

{

cout<<"*";

}

cout<<'\n';

}

Page 6: Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include  #include  using namespace std; main { int p, q, r; p=5;

for (q=3; q<=p; q++)

{

cout<<setw(q);

for (r=p; r>=q; r--)

{

cout<<"*";

}

for (r=p-1; r>=q; r--)

{

cout<<"*";

}

cout<<'\n';

}

cout<<'\n';

system ("pause");

return 0;

}

Hasilnya

Page 7: Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include  #include  using namespace std; main { int p, q, r; p=5;

Latihan Soal 1.B

Page 8: Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include  #include  using namespace std; main { int p, q, r; p=5;
Page 9: Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include  #include  using namespace std; main { int p, q, r; p=5;

Bahasa C++

#include <iostream>

#include <iomanip.h>

using namespace std;

main ()

{

int p, q, r;

p=5;

cout<<"Latihan Soal 1.b\n\n";

for (q=p; q>=2; q--)

{

cout<<setw(q);

for (r=q; r<=p; r++)

{

cout<<"*";

}

for (r=q+1; r<=p; r++)

{

cout<<"*";

}

Page 10: Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include  #include  using namespace std; main { int p, q, r; p=5;

cout<<'\n';

}

cout<<'\n';

system ("pause");

return 0;

}

Hasilnya

Page 11: Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include  #include  using namespace std; main { int p, q, r; p=5;

Latihan Soal 1.C

Page 12: Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include  #include  using namespace std; main { int p, q, r; p=5;
Page 13: Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include  #include  using namespace std; main { int p, q, r; p=5;
Page 14: Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include  #include  using namespace std; main { int p, q, r; p=5;

Bahasa C++

#include <iostream>

#include <iomanip.h>

using namespace std;

main ()

{

int p, q, r;

p=5;

cout<<"Latihan Soal 1.c\n\n";

for (q=p; q>=2; q--)

{

for (r=q; r<=p; r++)

{

cout<<"*";

}

for (r=q+1; r<=p; r++)

{

cout<<"*";

}

cout<<'\n';

Page 15: Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include  #include  using namespace std; main { int p, q, r; p=5;

}

for (q=3; q<=p; q++)

{

for (r=p; r>=q; r--)

{

cout<<"*";

}

for (r=p-1; r>=q; r--)

{

cout<<"*";

}

cout<<'\n';

}

cout<<'\n';

system ("pause");

return 0;

}

Page 16: Nama :Rheza Ariyanto Kelas :TKJ 1B · Kelas :TKJ 1B . Latihan Soal 1.A. Bahasa C++ #include  #include  using namespace std; main { int p, q, r; p=5;

Hasilnya