Wednesday, 3 October 2012

Under Standing Loops


Question :1

 #include<stdio.h>
 #include<conio.h>
 void main()
 {
 int i,sp=40,s=0,m,j;
 clrscr();
 for(int k=0;k<=7;k++)
{

for (i=1;i<=sp;i++)
  {printf(" ");}
    printf("*");

       if (k==3)
   {
   printf(" * * *\n");}
    sp=sp-1;
   if(k!=3)
   {
for (i=1;i<=s;i++)
  {printf(" ");}
     printf("*\n");

}
   s=s+2;

} getch();
 }

Question 2:

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=5;i>=1;i--)
{
for (j=1;j<=i;j++)
{
printf("%d",i);
}
printf("\n");
}
getch();
}

No comments:

Post a Comment