Ad

Chapter - 4: The Loop Control Structure

Write a program to produce the following output:


Ad
E
Sections
7
Exercises
A B C D E F 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


#include<stdio.h>
#include<conio.h>
int main()
{
	int i,a=71,l,j,b=1,c=71,k;
	for(l=1;l<=7;l++)
	{
		for(i=65;i<=a;i++)
			printf("%c", i);
		
		if(l>1)//space loop
		{
					
			for(j=1;j<=b;j++)
				printf(" ");
				b=b+2;
		}
		
		for(k=c;k>=65;k--)
		{
			if(k==71)
				continue;
			printf("%c", k);
		}
		
		printf("\n");
		a--;
		
		c--;
	}
	getch();
	return 0;
}
Ad

© 2024 Garbage Valuegarbage value logo