Last active
December 15, 2023 11:49
-
-
Save abdullahainun/4ea081bab8daa771fca1cad4bc1c4593 to your computer and use it in GitHub Desktop.
Program Bahasa C Persegi Angka
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
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
sample output: