Write a C program to print right triangle of consecutive row alphabets pattern using for loop.
#include <stdio.h> int main() { int alphabet, val, rows; printf("Enter Right Triangle of Consecutive Row Alphabets Rows = "); scanf("%d", &rows); printf("Right Triangle of Consecutive Row Alphabets Pattern\n"); alphabet = 64; for (int i = 1; i <= rows; i++) { val = i; for (int j = 1; j <= i; j++) { printf("%c ", alphabet + val); val = val + rows - j; } printf("\n"); } }
This C program displays the right angled triangle of consecutive alphabets using a while loop.
#include <stdio.h> int main() { int i, j, alphabet, val, rows; printf("Enter Right Triangle of Consecutive Row Alphabets Rows = "); scanf("%d", &rows); printf("Right Triangle of Consecutive Row Alphabets Pattern\n"); alphabet = 64; i = 1; while (i <= rows) { val = i; j = 1; while (j <= i) { printf("%c ", alphabet + val); val = val + rows - j; j++; } printf("\n"); i++; } }
Enter Right Triangle of Consecutive Row Alphabets Rows = 9
Right Triangle of Consecutive Row Alphabets Pattern
A
B J
C K R
D L S Y
E M T Z _
F N U [ ` d
G O V \ a e h
H P W ] b f i k
I Q X ^ c g j l m
This C example code uses the do while loop to print the right angled triangle of consecutive row alphabets pattern.
#include <stdio.h> int main() { int i, j, alphabet, val, rows; printf("Enter Right Triangle of Consecutive Row Alphabets Rows = "); scanf("%d", &rows); printf("Right Triangle of Consecutive Row Alphabets Pattern\n"); alphabet = 64; i = 1; do { val = i; j = 1; do { printf("%c ", alphabet + val); val = val + rows - j; } while (++j <= i); printf("\n"); } while (++i <= rows); }
Enter Right Triangle of Consecutive Row Alphabets Rows = 10
Right Triangle of Consecutive Row Alphabets Pattern
A
B K
C L T
D M U \
E N V ] c
F O W ^ d i
G P X _ e j n
H Q Y ` f k o r
I R Z a g l p s u
J S [ b h m q t v w