Saturday, January 30, 2010

CHAP 3[E]f Making alphabet patterns

Write a program to produce the following output:













void main()
{

int d,a,b,e,f;
printf("\nInput a value from 66 to 90\n");
scanf("%d",&b);
f=b-65;
for(a=0;a<=f;a++)
{
printf("\n");

for(d=65;d<=b;d++)
printf("%c",d);


if(a>0)
{
e=2*a-1;
for(;e>0;e--)
printf("%c",0);
}

if(a==0)
b=b-1;

for(d=b;d>=65;d--)
printf("%c",d);

if(a==0)
b=b+1;

b=b-1;
}
}

6 comments:

  1. #include
    #include

    main()
    {
    int a,b,c,d,e;
    clrscr();

    for(b=7;b>0;b--)
    {
    for(a=0;a<7;a++)
    {
    if(a=0;a--)
    {
    if(a<b)
    printf("%c ",a+65);
    else
    printf(" ");
    }
    printf("\n");
    }
    getch();
    return 0;
    }

    ReplyDelete
  2. Use this logic
    #include
    #include
    void main(void)
    {
    int iteration, space, last=70,new_value=70, put_space=1;
    char alphabet;
    printf("ABCDEFGFEDCBA\n");
    for (iteration=1; iteration<=6; iteration++)
    {
    for (alphabet=65; alphabet<=last; alphabet++)
    {
    printf("%c", alphabet);
    continue;
    }
    last--;
    for (space=1; space<=put_space; space++)
    { printf("%c", 32); }
    put_space=put_space+2;
    for (alphabet=new_value; alphabet>=65; alphabet--)
    {
    printf("%c", alphabet);
    continue;
    }
    new_value--;
    printf("\n");
    }
    }

    OR

    #include
    #include
    void main(void)
    {
    int i,n=65,m=72,f=0,s=-6;
    clrscr();
    while(m-->=n)
    {
    s+=4;
    for(i=n;i=n;i--)
    printf("%c ",i);
    printf("\n");f=1;
    }
    getch();
    }

    ReplyDelete
  3. try this 1,
    main()
    {
    int y,sp,t;
    char a,x;
    printf("Enter reference alphabet (in capital):");
    scanf("%c",&a);
    t=a;
    for (y=1;y<=(t-64);y++)
    {
    for (x=65;x<=a;x++)
    printf("%c",x);
    for (sp=1;sp<=(2*y-3);sp=sp+1)
    printf(" ");
    if (x==(t+1))
    x--;
    {
    for (x=x-1;x>=65;x--)
    printf("%c",x);
    }
    printf("\n");
    a--;
    }
    getch();
    }

    ReplyDelete
    Replies
    1. in sp loop i cant under stand why you write sp<=(2*y-3) please explain logic of this term

      Delete
  4. #include
    #include
    int main(){
    int c, d, a, i, j;
    for(i=6; i>=0;i--){
    c=i;
    d=i;
    a=0;
    for(j=0; j<=i;j++){
    printf("%c",j+65);
    }

    while(c!=6){
    printf(" ");
    c++;
    a++;
    }
    while(a>1){
    printf(" ");
    a--;
    }
    if(d==6){
    d=d-1;
    }
    while(d>=0){
    printf("%c", d+65);
    d--;
    }
    printf("\n"); }

    return 0;
    }

    ReplyDelete
  5. #include
    #include

    int main()
    {
    int i,j,n;

    scanf("%d",&n);
    printf("\n\n\n");
    for(i=-(n-1);i<=0;i++)
    {
    for(j=-(n-1);j<=(n-1);j++)
    {
    if(abs(i)+abs(j)<(n-1))
    printf(" ");
    else
    printf("%c",n-abs(j)+64);
    }
    printf("\n");
    }
    return 0;
    }

    ReplyDelete