The need:
This program was asked by a reader.
The code:---------------------------------------------------------
#include<stdio.h> main() { char z; int j,i,k; printf("Enter the number of rows..(1 to 26)\t"); scanf("%d",&k); if(k<1||k>26) { printf("\nThe number entered was not in range of 1 to 26\n"); printf("exiting...\n"); exit(0); } printf("\n\n"); for (i=0;i<k;i++) { z = 'A'; for (j=0;j<k;j++) { if(j<k-i) printf ("%c ",z); else printf("_ "); z++; } z--; for (j=k;j>0;j--) { if(j<=k-i) printf ("%c ",z); else printf("_ "); z--; } printf("\n\n"); } }---------------------------------------------------------
Output:
output of the program will be some thing like this:
sample output when input 8 is given.
A B C D E F G H H G F E D C B A A B C D E F G _ _ G F E D C B A A B C D E F _ _ _ _ F E D C B A A B C D E _ _ _ _ _ _ E D C B A A B C D _ _ _ _ _ _ _ _ D C B A A B C _ _ _ _ _ _ _ _ _ _ C B A A B _ _ _ _ _ _ _ _ _ _ _ _ B A A _ _ _ _ _ _ _ _ _ _ _ _ _ _ A
i got parse error on executing this
ReplyDelete????
try now... :)
ReplyDelete