Hello friends today i'm sharing an interesting program with all of you just read the code this is very easy code ,you can easily understand it by simple concepts of c language.If you find any difficulty when reading it please share with me,i'll try to sort out your problem.
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j;
clrscr();
printf("\n HERE IS YOUR PATTERN:\n\n");
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
if(i%2==0)
{
if(j%2==0)
printf(" 1");
else
printf(" 0");
}
else
{
if(j%2==0)
printf(" 0");
else
printf(" 1");
}
}
printf("\n");
}
getch();
return(0);
}
1 0 1 1 0 1 0 1 0 1 1 0 1 0 1
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j;
clrscr();
printf("\n HERE IS YOUR PATTERN:\n\n");
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
if(i%2==0)
{
if(j%2==0)
printf(" 1");
else
printf(" 0");
}
else
{
if(j%2==0)
printf(" 0");
else
printf(" 1");
}
}
printf("\n");
}
getch();
return(0);
}
Thanks Friends...
Write a program to print the following pattern based on user input.
ReplyDeleteFor eg: If N=4 the code should print the following pattern.
1*2*3*4*17*18*19*20
--5*6*7*14*15*16
----8*9*12*13
------10*11
Again if N=5 the code should print
1*2*3*4*5*26*27*28*29*30
--6*7*8*9*22*23*24*25
----10*11*12*19*20*21
------13*14*17*18
--------15*16
For N=2 the pattern will be
1*2*5*6
--3*4
I could never frame the code.Please help.
Sure i will help you.
ReplyDeleteI will try to make this program.
Once completed i will post in my blog.
t0 print
ReplyDelete10001
01010
00100
01010
10001