Tuesday 10 July 2012

Print "Z" alphabet in C


#include<stdio.h>
#include<conio.h>

/* print z in stars*/
void main()
{
int i=0, y=1, space, sp=1, limit;


clrscr();


printf("enter the limit");
scanf("%d",&limit);
space=limit-2;


     while (i++<limit)
     {
if(i==1|| i==limit)
  {
  while(y++ <= limit)
  {
  printf("*");
  }
y=1;
  printf("\n");
}
else
{
 while(sp++<=space)
  {
                   printf(" ");
    }


  printf("*");
  space--;
  printf("\n");
  sp=1;
  }
}

getch();
}

No comments:

Post a Comment