I just started CS 50 and there's a challenge to make a right-aligned pyramid. In the code below it it works well for the first time round but it prints this:
# # # # # #I don't understand why.
#include<stdio.h>void row(int i) { for (int y = 0; y < i ; y++) { int k = 3 - i; if (k > 0 ) { for (int x = 0 ; x < k ; x++) { printf(" "); } } printf("#"); } printf("\n");}int main(void) { int len = 3; for (int ye = 0; ye < len ; ye++) { row(ye+1); }}I also replaced the k = 3 -y with-i but that prints
# # ####I ended up solving the challenge in the bed but I'm still not getting what's wrong here if anyone can explain that would awesome and greatly appreciated
For context I was expecting this
# #####