Last active
October 18, 2020 21:28
-
-
Save defrindr/289a933e607f49fb57550f2d86c9ba7b to your computer and use it in GitHub Desktop.
This file contains hidden or 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() | |
{ | |
int n; | |
printf("Masukkan Inputan ? "); | |
scanf("%d", &n); | |
for(int i = 1; i <= n; i++) { | |
int result = 0; | |
for(int j=1; j <= i;j++) result += i; | |
printf("%d ", result); | |
} | |
return 0; | |
} |
This file contains hidden or 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() | |
{ | |
int n; | |
printf("Masukkan Inputan ? "); | |
scanf("%d", &n); | |
for (int line = 1; line <= n; line++) | |
{ | |
int C = 1; | |
// print spacing | |
int count = (int)n - line; | |
printf("%*s", count, ""); | |
for (int i = 1; i <= line; i++) | |
{ | |
// print number | |
printf("%d ",C); | |
C = C * (line - i) / i; | |
} | |
printf("\n"); | |
} | |
return 0; | |
} | |
// This code is contributed by Code_Mech | |
// original source : https://www.geeksforgeeks.org/pascal-triangle/ | |
// with minor modification |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment