#Make a pattern with C
1 messages · Page 1 of 1 (latest)
What have you got so far? Anything?
I got a wrong pattern like
s
sd
sdds
What's your code?
Hmm, you'd need nested loops. And pay attention to special chars 👀 since i see $ sign there and not a letter
#include<stdio.h>
int main(){
char fi, se;
int line, i, j, k;
printf("Enter 1st: ");
scanf(" %c", &fi);
printf("Enter 2nd: ");
scanf(" %c", &se);
printf("Enter lines: ");
scanf("%d", &line);
for(i = 0; i < line; i++){
printf("%c", fi);
for(j = 0; j < i; j++){
printf("%c", se);
for(k = 0; k < j; k++){
printf("%c", fi);
}
}
printf("\n");
}
return 0;
}
this my code
Any idea ?
Why 3 for loops?
And why declare variables used in loops at the top of main? X_X
i figure it out