How to print the alphabets in left right right left pattern with C

1 Answer

0 votes
#include <stdio.h>

int main(void) {
    int rows = 13, line_number = 1;
     
    if (rows <= 13 && rows >=1) {
        for (int i = 1; i <= rows * 2; i += 2) {
            if (line_number % 2 == 1) {
                printf("%c %c", i + 64, i + 65);
            } else {
                printf("%c %c", i + 65, i + 64);
            }
            line_number++;
            printf("\n");
      }
   }
   return 0;
}




/*
run:
 
A B
D C
E F
H G
I J
L K
M N
P O
Q R
T S
U V
X W
Y Z
 
*/

 



answered Sep 25, 2021 by avibootz
edited Sep 25, 2021 by avibootz

Related questions

...