+ 3

AnyOne Can Print This Pattern In C Language?

Print This - CBA BA A

19th Apr 2018, 8:47 AM
Zuhaib
Zuhaib - avatar
9 Respostas
19th Apr 2018, 10:36 AM
ThiemTD
ThiemTD - avatar
+ 4
ho 😅 sory
19th Apr 2018, 9:42 AM
Mohammed Rameez
Mohammed Rameez - avatar
+ 4
Zuhaib what is with this pattern and you have 4 posts about it?
19th Apr 2018, 9:46 AM
dim_knp
dim_knp - avatar
+ 3
done
19th Apr 2018, 9:59 AM
Mohammed Rameez
Mohammed Rameez - avatar
+ 3
i don't know. 😅
19th Apr 2018, 10:12 AM
dim_knp
dim_knp - avatar
+ 2
like this right?🤔 printf("CBA\nBA\nA\n"); if i WRONG tell me gys ok plz
19th Apr 2018, 9:27 AM
Mohammed Rameez
Mohammed Rameez - avatar
19th Apr 2018, 10:09 AM
dim_knp
dim_knp - avatar
+ 2
what happend man?😃
19th Apr 2018, 10:10 AM
Mohammed Rameez
Mohammed Rameez - avatar
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.
22nd Apr 2018, 10:29 AM
Lukas Weber
Lukas Weber - avatar