Pattern 13
write a prog. to print following pattern
#include<conio.h>
#include<stdio.h>
void main()
{
int n=0,i,j;
clrscr();
printf("Enter N:");
scanf("%d",&n);
printf("\n\n");
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
if(j%2==0)
printf("1");
else
printf("0");
}
printf("\n");
}
getch();
}
/****************** OR ******************/
#include<conio.h>
#include<stdio.h>
void main()
{
int n=0,i,j;
clrscr();
printf("Enter N:");
scanf("%d",&n);
printf("\n\n");
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",(j%2));
}
printf("\n");
}
getch();
}
O/P:
write a prog. to print following pattern
1
10
101
1010
10101#include<conio.h>
#include<stdio.h>
void main()
{
int n=0,i,j;
clrscr();
printf("Enter N:");
scanf("%d",&n);
printf("\n\n");
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
if(j%2==0)
printf("1");
else
printf("0");
}
printf("\n");
}
getch();
}
/****************** OR ******************/
#include<conio.h>
#include<stdio.h>
void main()
{
int n=0,i,j;
clrscr();
printf("Enter N:");
scanf("%d",&n);
printf("\n\n");
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",(j%2));
}
printf("\n");
}
getch();
}
O/P:
No comments:
Post a Comment