WAP to print the following numerical patterns
1)
5 5 5 5 54 4 4 4
3 3 3
2 2
1
2)
!! !
! ! !
! ! ! !..upto n
3)
** *
* * *
* * * *.. upto n
4)
11 2
1 2 3
1 2 3 4..upto n
5)
12 2
3 3 3
4 4 4 4..upto n
6)
* * *
* * *
* * * *..upto n
7)
1 2 1
3 2 1
4 3 2 1..upto n
8)
1 2 2
3 3 3
4 4 4 4..upto n
Click here to see solutions
prog: 1)
#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();
}
prog: 2)
#include#include
void main()
{
int i, j, n;
printf("Enter the limit: ");
scanf("%d", &n);
for (i=1; i<=n; i++)
{
for(j=1; j<=i; j++)
{
printf(" ! "); // now replace ! with any character
}printf("\n");
}
getch();
}
prog: 3)
#include#include
void main()
{
int i, j, n;
printf("Enter the limit: ");
scanf("%d", &n);
for (i=1; i<=n; i++)
{
for(j=1; j<=i; j++)
{
printf(" * ");
}
printf("\n");
}
getch();
}
prog: 4)
#include"stdio.h"#include"conio.h"
void main()
{
int i, j;
clrscr();
for(i=1; i<=n; i++)
{
for(j=1; j<=i; j++)
{
printf("%d ", j);
}
printf("\n ");
}
getch();
}
prog: 5)
#include"stdio.h"#include"conio.h"
void main()
{
int i, j;
clrscr();
for(i=1; i<=n; i++)
{
for(j=1; j<=i; j++)
{
printf("%d ", i);
}
printf("\n ");
}
getch();
}
prog: 6)
#include"stdio.h"#include"conio.h"
void main()
{
int i, j, k, n;
clrscr();
printf("Enter the limit : ");
scanf("%d", &n);
for(i=1; i<=n; i++)
{
for(k=n-1; k>=i; k--)
{
printf(" ");
}
for(j=1; j<=i; j++)
{
printf("*");
}
printf("\n ");
}
getch();
}
prog: 7)
#include"stdio.h"#include"conio.h"
void main()
{
int i, j, k, n;
clrscr();
printf("Enter the limit : ");
scanf("%d", &n);
for(i=1; i<=n; i++)
{
for(k=n-1; k>=i; k--)
{
printf(" ");
}
for(j=i; j>=1; j--)
{
printf("%d", j);
}
printf("\n ");
}
getch();
}
prog: 8)
#include"stdio.h"#include"conio.h"
void main()
{
int i, j, k, n;
clrscr();
printf("Enter the limit : ");
scanf("%d", &n);
for(i=1; i<=n; i++)
{
for(k=n-1; k>=i; k--)
{
printf(" ");
}
for(j=i; j>=1; j--)
{
printf("%d", i);
}
printf("\n ");
}
getch();
}
0 comments:
Post a Comment
If you have any proble fee free to ask it here