+ 1
Program using nested for loop?
1 12 123 1234 Code to print it on the right side Like 1 2 1 321 4321 I tried this #include <stdio.h> int main() { int ct,gk; for(ct=1;ct<=4;ct++) { for(gk=1;gk<=ct;++gk) { printf("%d",gk); } printf("\n"); } return 0; }
6 Respuestas
+ 6
For right aligned printing
#include <stdio.h>
int main()
{
int ct, gk, p;
for (ct = 1, p = 3; ct <= 4; ct++)
{
// print padding spaces
if(p) printf("%*c", p--, ' ');
// loop backwards
for (gk = ct; gk >= 1; --gk)
printf("%d", gk);
printf("\n");
}
return 0;
}
+ 6
what do you need help with? 😅
(and a side note, it hurts to see unindented code 😩, it makes it alot harder to understand the code and just doesn't look pretty and clean 😅)
+ 4
You're welcome Alfred,
Next time around, please save the code in your profile, and share the link instead, easier for review, and yes, need a little work with code indentation 😁
+ 3
Ipang Thank you I understood
+ 3
Anton Böhler ok I will try to take care of that from next time
+ 1
Ipang hmm ok😊