Skip to content

Instantly share code, notes, and snippets.

@abdullahainun
Last active December 15, 2023 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdullahainun/4ea081bab8daa771fca1cad4bc1c4593 to your computer and use it in GitHub Desktop.
Save abdullahainun/4ea081bab8daa771fca1cad4bc1c4593 to your computer and use it in GitHub Desktop.
Program Bahasa C Persegi Angka
#include <stdio.h>
int main(void)
{
printf("## Program Bahasa C Persegi Angka ## \n");
printf("====================================== \n\n");
int besar_persegi,baris,kolom, i,j;
printf("Input besar persegi: ");
scanf("%d",&besar_persegi);
printf("\n");
for(baris=1; baris<=besar_persegi; baris++) {
if (baris % 2 == 0) {
for(kolom=besar_persegi; kolom>=1; kolom--) {
printf(" %d", kolom);
}
}else{
for(kolom=0; kolom<=besar_persegi-1; kolom++) {
printf(" %d", kolom);
}
}
printf("\n");
}
return 0;
}
@abdullahainun
Copy link
Author

sample output:

image

@abdullahainun
Copy link
Author

How to run

  • Compile source code
$ gcc main.c -o tes
  • Run app
$ ./tes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment