Wednesday, 8 September 2021

Write a program to print the diamod shaped Pyramid of alphabets.....

 #include<stdio.h>
#include<conio.h>

void main()
{
	
	int i,j,rows,k;
	
	printf("Enter a number to define the rows :");
	scanf("%d",&rows);
	
	int space=rows-1,num=1;
	printf("\n");
	for(i=1;i<=rows;i++)
	{
		for(j=1;j<=space;j++)
		{
			printf(" ");
			
		}
		for(k=1;k<=num;k++)
		{
			printf("%c",'A'+k-1);
		}
		
		if(space>i)
	{
		space=space-1;
		
		num=num+2;
	}
	if(space<i)
	{
		space=space+1;
		
		num=num-2;
	}
	printf("\n");
	
	}
	
	getch();
}



No comments:

Post a Comment

Program to check whether the reverse string is a palindrome

  # include < stdio.h > # include < string.h > int main ( ) { //declare variables char str1 [ 30 ] ; int i , len...