Lecture 11 Oct 28 2019
Lecture 11 Oct 28 2019
0 0 0 0 0 0
1 1 1 1 1 1
2 2 2 2 2 2
3 3 3 3 3 3
4 4 4 4 4 4
0 1 2 3 4
0 1 2 3 4
0 1 2 3 4
0 1 2 3 4
0 1 2 3 4
0 1 2 3 4
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
Do These Yourself
Dr. Yousaf, PIEAS
Try to modify the previous program such that
the program prints the following pattern
#include<stdio.h>
int main ()
{ int i, j, k;
for(i=0;i<5;i++)
{
for (j = 5; j > i+1; j--)
printf(" ");
for(k=0; k<=i; k++)
printf("*");
printf("\n");
}
getchar(); return 0; }
Dr. Yousaf, PIEAS
Try to modify the previous program such that
the program prints the following pattern
#include<stdio.h>
int main()
{ int i, j;
for(i=1;i<=5;i++)
{ for(j=5;j>=1;j--)
{
if(j<=i) printf("*");
else printf(" ");
}
printf("\n");
}
getchar();return 0;}
Dr. Yousaf, PIEAS
Try to write the program to print the
following pattern
*****
* * * * * ** * *
********* Do It Yourself
*********
*********
*******
*****
•* * * * *
**
Dr. Yousaf, PIEAS