Dan berikut ini adalah coding dari perulangan segitiga bintang.
Output
Source Code
#include"stdio.h"
#include"conio.h"
main()
{
printf ("Nama :Yudha Niagara\n");
printf ("NPM :G1A014047\n");
printf ("====================\n\n");
{
int baris, kolom, y, nilai ;
printf ("Deret segitiga bintang 5 baris\n");
for (baris=1 ;baris<=5; baris++){
for (kolom=10 ;kolom>=baris ;kolom--){
printf (" ");
}
for (y=1 ;y<=baris ;y++)
printf ("*");
for (y=1 ;y<baris ;y++)
printf ("*");
printf ("\n");
}
printf ("==============================\n\n");
printf ("Masukan jumlah baris : ");
scanf ("%d", &nilai);
for (baris=1 ;baris<=nilai ;baris++){
for (kolom=(nilai+5) ;kolom>=baris ;kolom--){
printf(" ");
}
for (y=1 ;y<=baris ;y++)
printf ("*");
for (y=1 ;y<baris ;y++)
printf ("*");
printf ("\n");
}
}
return 0;
}
#include"conio.h"
main()
{
printf ("Nama :Yudha Niagara\n");
printf ("NPM :G1A014047\n");
printf ("====================\n\n");
{
int baris, kolom, y, nilai ;
printf ("Deret segitiga bintang 5 baris\n");
for (baris=1 ;baris<=5; baris++){
for (kolom=10 ;kolom>=baris ;kolom--){
printf (" ");
}
for (y=1 ;y<=baris ;y++)
printf ("*");
for (y=1 ;y<baris ;y++)
printf ("*");
printf ("\n");
}
printf ("==============================\n\n");
printf ("Masukan jumlah baris : ");
scanf ("%d", &nilai);
for (baris=1 ;baris<=nilai ;baris++){
for (kolom=(nilai+5) ;kolom>=baris ;kolom--){
printf(" ");
}
for (y=1 ;y<=baris ;y++)
printf ("*");
for (y=1 ;y<baris ;y++)
printf ("*");
printf ("\n");
}
}
return 0;
}
Untuk fungsi, algoritma, pseudocode, dan flowchart silahkan request by email.
yudhaniagara27@gmail.com
0 comments:
Post a Comment
https://www.instagram.com/endskuulzyr027st.blogspot.com_/