Sunday, 17 March 2013

Write a C program to print the following pattern: A B A C B A D C B A E D C B A

#include <stdio.h>

int main() {
	char prnt = 'A';
	int i, j;
	for (i = 1; i <= 5; i++) { // Prints the right angle triangle
		for (j = 1; j <= i; j++) {
			printf("%2c", ((prnt + (i - j))));  // Prints the characters in the required order
		}
		printf("\n");
	}
	return 0;
}

No comments:

Post a Comment