Use nested loops to produce a pattern based on letter 2 - C Statement

C examples for Statement:for

Description

Use nested loops to produce a pattern based on letter 2

A
BC
DEF
GHIJ
KLMNO
PQRSTU

Demo Code


#include <stdio.h>

int main(void){
  char c = 'A';

  for (int i = 1; i < 7; i++){
    for(int j = 1; j <= i; j++){
      printf("%c", c++); // print and THEN increment c
    }//from  w  ww .j  a  v  a2 s.  c o m
    printf("\n");
  }

  return 0;
}

Result


Related Tutorials