+ 3
AnyOne Can Print This Pattern In C Language?
Print This - CBA BA A
9 Answers
+ 2
Please see more here: https://code.sololearn.com/cNv7xE6qQciW/#cpp
+ 4
ho đ
sory
+ 4
Zuhaib what is with this pattern and you have 4 posts about it?
+ 3
done
+ 3
i don't know. đ
+ 2
like this right?đ€
printf("CBA\nBA\nA\n");
if i WRONG tell me gys ok plz
+ 2
Mohammed Rameez đ
+ 2
what happend man?đ
0
If you *really* want to use a loop for that..
//allocating and filling the array
char cs* = calloc(3, sizeof char);
for(int i = 0; i < 3; i++)
cs[i] = 'A'+i;
//printing
for(int i = 0; i < 4; i++){//3 chars down to 0
for(int j = 0; j < 3; j++){
//replace chars with a space when it shouldn't bei printed
printf("%c", j < i ? ' ':cs[j]);
}
printf("\n");
}
//don't forget to clean up
free(cs);
Small disclaimer: I write my C code very Java-like ({} placement, variable declarations within head of for loops).
The GCC Compiler don't mind that but if you want *correct* ANSI C you may want to rewrite some of that.