Q. Write a C program to print the following triangle.
A | ||||||||
A | B | A | ||||||
A | B | C | B | A | ||||
A | B | C | D | C | B | A | ||
A | B | C | D | E | D | C | B | A |
Ans.
#include<stdio.h>
#include<conio.h>
int main()
{
char ch,r,c;
int sp;
printf("Enter character : ");
scanf("%c",&ch);
if(ch>='a' && ch<='z')
ch=ch-32;
for(r='A'; ch>=r; r++)
{
for(sp=ch-r; sp>=1; sp--)
printf(" ");
for(c='A'; r>=c; c++)
printf("%c",c);
for(c=r-1; c>='A'; c--)
printf("%c",c);
printf("\n");
}
getch();
return 0;
}
/*************** OUTPUT ******************
Enter character : E
A | ||||||||
A | B | A | ||||||
A | B | C | B | A | ||||
A | B | C | D | C | B | A | ||
A | B | C | D | E | D | C | B | A |
Write a program that display the following output. (Use nested for loop)
ReplyDeleteA
ABA
ABCBA
ABCDCBA
ABCDEDCBA
ABCDEFEDCBA
ABCDEFGFEDCBA
ABCDEFGHGFEDCBA
ABCDEFGHIHGFEDCBA
ABCDEFGHIJIHGFEDCBA
ABCDEFGHIJKJIHGFEDCBA
ABCDEFGHIJKLJIHGFEDCBA
ABCDEFGHIJKLMLJIHGFEDCBA
ABCDEFGHIJKLMNMLJIHGFEDCBA
ABCDEFGHIJKLMNONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTSRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUTSRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVUTSRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWVUTSRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXWVUTSRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYXWVUTSRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYZYXWVUTSRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYZYXWVUTSRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYXWVUTSRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXWVUTSRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWVUTSRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVUTSRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUTSRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTSRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQRQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPQPONMLJIHGFEDCBA
ABCDEFGHIJKLMNOPONMLJIHGFEDCBA
ABCDEFGHIJKLMNONMLJIHGFEDCBA
ABCDEFGHIJKLMNMLJIHGFEDCBA
ABCDEFGHIJKLMLJIHGFEDCBA
ABCDEFGHIJKLJIHGFEDCBA
ABCDEFGHIJKJIHGFEDCBA
ABCDEFGHIJIHGFEDCBA
ABCDEFGHIHGFEDCBA
ABCDEFGHGFEDCBA
ABCDEFGFEDCBA
ABCDEFEDCBA
ABCDEDCBA
ABCDCBA
ABCBA
ABA
A
@
DeleteYour required above character pyramid source code at:
http://cprogrammingcodes.blogspot.in/2014/02/character-pyramid.html
Write a program that display the following output. (Use nested for loop)
ReplyDeleteA
ABA
ABCBA
ABCDCBA
ABCDEDCBA
ABCDEFEDCBA
ABCDEFGFEDCBA
ABCDEFGHGFEDCBA
ABCDEFGHIHGFEDCBA
ABCDEFGHIJIHGFEDCBA
ABCDEFGHIJKJIHGFEDCBA
ABCDEFGHIJKLJIHGFEDCBA
ABCDEFGHIJKLMLJIHGFEDCBA
ABCDEFGHIJKLMNMLJIHGFE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