Aim: 5.1 Write a program to print following pattern :
*
* *
* * *
* * * *
* * * * *
Code:
#include <stdio.h>
int main()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<=i;j++)
{
printf(" *");
}
printf("\n");
}
return 0;
}
Output screenshot:
Aim: 5.2 Write a program to print following pattern :
Code:
#include <stdio.h>
int main()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=i+1;j<5;j++)
{
printf(" ");
}
for(j=0;j<=i;j++)
{
printf(" *");
}
printf("\n");
}
return 0;
}
Output screenshot:
Aim: 5.3 Write a program to print following pattern :
Code:
#include <stdio.h>
int main()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<i;j++)
{
printf(" ");
}
for(j=i;j<5;j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
Output screenshot:
Aim: 5.4 Write a program to print following pattern :
1
12
123
1234
12345
Code:
#include <stdio.h>
int main()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<=i;j++)
{
printf("%d",j+1);
}
printf("\n");
}
return 0;
}
Output screenshot:
Aim: 5.5 Write a program to print following patterns :
Code:
#include <stdio.h>
int main()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<5-i;j++)
{
printf("%d",j+1);
}
printf("\n");
}
return 0;
}
Output screenshot:
Aim: 5.6 Write a program to print following patterns :
Code:
#include <stdio.h>
int main()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<5-i;j++)
{
printf("%d",5-i);
}
printf("\n");
}
return 0;
}
Output screenshot:
Aim: 5.7 Write a program to print following patterns :
Code:
#include <stdio.h>
int main()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<=i;j++)
{
printf("%d",i+1);
}
printf("\n");
}
return 0;
}
Output screenshot:
Aim: 5.8 Write a program to print following patterns :
Code:
#include <stdio.h>
int main()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=5;j>i;j--)
{
printf("%c",'A'+i);
}
printf("\n");
}
return 0;
}
Output screenshot:
Aim: 5.9 Write a program to print following patterns :
Code:
#include <stdio.h>
int main()
{
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<5-i;j++)
{
printf("%c",'A'+j);
}
printf("\n");
}
return 0;
}
Output screenshot:
No comments:
Post a Comment
If you have any doubts or suggestions, Please let me know