Monday, 8 December 2014

C Program to print RHOMBUS pattern using alphabets

Program to print pattern
#include<stdio.h>
main()
{
int i,j,k,n;
char ch='A';
printf("enter value for n\n");
scanf("%d",&n);
for(i=-n;i<=n;i++)
{
k=i;
if(k<0)
k=-k;
for(j=0;j<=n;j++)
{
if(j<=k)
printf(" ");
else
{
printf("%c ",ch);
ch++;
}
}
printf("\n");
}
}
OutPut:
madan@madan-Lenovo-G570:~/madan$ cc pyramid3.c
madan@madan-Lenovo-G570:~/madan$ ./a.out
enter value for n
5
      
     A 
    B C 
   D E F 
  G H I J 
 K L M N O 
  P Q R S 
   T U V 
    W X 
     Y