Skip to content

Instantly share code, notes, and snippets.

@defrindr
Last active October 18, 2020 21:28
Show Gist options
  • Save defrindr/289a933e607f49fb57550f2d86c9ba7b to your computer and use it in GitHub Desktop.
Save defrindr/289a933e607f49fb57550f2d86c9ba7b to your computer and use it in GitHub Desktop.
#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;
}
#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