0

Please check out This
Output required

Aa
      Cc Bb
   Dd Ee Ff
jj Ii Hh Gg
#include<stdio.h>
#include<conio.h>
void main()
{
 char a = 'a',a1 ='a',A = 'A',A1='A';
 int i,j,n;
 clrscr();
 for(i =1;i<=4;i++,printf("\n"))
 {
   if(i%2!=0)
   for(j = 1;j<=i;j++)
   {
       printf("%c%c ",a,A);
       a++;
       A++;
   }
   else
   {
    a1 = a-1;
    A1 = A-1;
   for(n = i;n>=1;n--)
    {
     printf("%c%c ",a1+n,A1+n);
     a++;
     A1++;
    }
   }
  }

}

Its comming partial right. That is small letters follow the pattern but big ones aren't.

Edited by Rahul.menon: n/a

3
Contributors
6
Replies
8
Views
6 Years
Discussion Span
Last Post by Rahul.menon
0
for(i =1;i<=4;i++,printf("\n"))

Do you really want that printf there?

Edited by Martin B: n/a

0

That A1++ on line 25 looks iffy to me.
It doesn't rhyme with the a++ on the previous line.

Edited by Martin B: n/a

0

hello,
plz tell me you wanna help or the exact code...
if you want help or hint I can tell you it is possible using nested loop like this

for (initialization ; condition; increment)
{
        for (initialization ; condition; increment)
        {
                // code for printing spaces because before your character
                // there are some spaces printed on the screen
        }
        for (initialization ; condition; increment)
        {
                // code for your alphabets
        |
}

this pattern will solve your problem....

and answer will

Aa
      Cc Bb
   Ff Ee Dd
Jj Ii Hh Gg

Edited by progneer.soft: n/a

0

I am helping you. I've just told you that the error is on line 25.
Can you really not tell what that line should be?
Did you write the code?

0
progneer.soft the pattern is 
         Aa
      Cc Bb
   Dd Ee Ff
jj Ii Hh Gg

and not
         Aa
      Cc Bb
   Ff Ee Dd
Jj Ii Hh Gg

I want the exact code my code is putting the small letters in right sequence,prblm is the bigs. Ideally it shdnt have been.

Edited by Rahul.menon: n/a

0

I got it must have been A++ line 25

Edited by Rahul.menon: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.