Monday, September 10, 2012

LOOP Program in c


(f) Write a program to produce the following output:
ABCDEFGFEDCBA
ABCDEF   FEDCBA
ABCDE       EDCBA
ABCD           DCBA
ABC                CBA
AB                     BA
A                          A

Solution:


#include<stdio.h>
main()
{
int i,j,k,m;
clrscr();
for(k=72;k>64;k--)
{
for(i=65;i<k;i++)
printf("%c",i);
for(m=2*(72-k)-1;m>0;m--)//for providing odd No. of spaces
printf(" ");
if(k==72)
j=k-2;
else
j=k-1;
for(j;j>64;j--)
printf("%c",j);

printf("\n");
}
}

1 comment:

  1. SEGA GENESIS: GENESIS - Videodl.cc
    SEGA GENESIS: GENESIS, one of the first to share videos of the youtube to mp3 ringtone classic SEGA GENESIS game console with millions of views on YouTube.

    ReplyDelete