5. Interesting Alphabets #

Created Friday 18 October 2019

Q) Print the following pattern for the given number of rows. Given pattern for N = 5 E DE CDE BCDE ABCDE Input format : N (Total no. of rows) Output format : Pattern in N lines Sample Input : 8 Sample Output : H GH FGH EFGH DEFGH CDEFGH BCDEFGH ABCDEFGH

Answer: q1) Number of rows = n, i from 1 to n q2) no of columns = i. q3) The nth alphabet, followed by the successors. We need to keep track of the first letter of each row, one way can be to store only the 1st letter as a calculation, an and the rest as code. char val = ‘A’+n-1; // gives the nth alphabet then we do val-- for each row. We also need a second variable for the row elements.