SOAL BAHASA C
using DEV++
#include <conio.h>
void main()
{
int rows, star, spaces;
int number_of_stars = 6; //set brp jumlah bintang
int number_of_rows = number_of_stars;
for (rows=1; rows <= number_of_rows; rows++) {
for (spaces=1; spaces <= number_of_stars; spaces++) {
printf(" ");
}
for (star=1; star <= rows; star++) {
printf("*");
printf(" ");
}
printf("\n");
number_of_stars = number_of_stars - 1;
}
printf(" RESPONSI");
printf("\n");
for (rows=number_of_rows; rows >=1; rows--) {
for (spaces=number_of_stars; spaces >= 1; spaces--) {
printf(" ");
}
for (star=rows; star >= 1; star--) {
printf(" ");
printf("*");
}
number_of_stars = number_of_stars + 1;
printf("\n");
}
}
using DEV++
Buatlah program
menggunkan PERULANGAN mencetak
bentuk seperti gambar dibawah ini
#include <stdio.h>#include <conio.h>
void main()
{
int rows, star, spaces;
int number_of_stars = 6; //set brp jumlah bintang
int number_of_rows = number_of_stars;
for (rows=1; rows <= number_of_rows; rows++) {
for (spaces=1; spaces <= number_of_stars; spaces++) {
printf(" ");
}
for (star=1; star <= rows; star++) {
printf("*");
printf(" ");
}
printf("\n");
number_of_stars = number_of_stars - 1;
}
printf(" RESPONSI");
printf("\n");
for (rows=number_of_rows; rows >=1; rows--) {
for (spaces=number_of_stars; spaces >= 1; spaces--) {
printf(" ");
}
for (star=rows; star >= 1; star--) {
printf(" ");
printf("*");
}
number_of_stars = number_of_stars + 1;
printf("\n");
}
}
Comments
Post a Comment