Number Pattern 3
/*
To print the following number pattern
1
2 3
4 5 6
7 8 9 10
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n,a=1;
clrscr();
printf("enter the range\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d ",a);
a=a+1;
}
printf("\n");
}
getch();
}
/*
output :-
------------
enter the range
4
1
2 3
4 5 6
7 8 9 10
*/
To print the following number pattern
1
2 3
4 5 6
7 8 9 10
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n,a=1;
clrscr();
printf("enter the range\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d ",a);
a=a+1;
}
printf("\n");
}
getch();
}
/*
output :-
------------
enter the range
4
1
2 3
4 5 6
7 8 9 10
*/
check this out
ReplyDeletehttp://cbasicprogram.blogspot.in/2012/04/number-patterns.html
This comment has been removed by the author.
ReplyDelete