C | Pattern Tutorials | with outputs
#include<stdio.h>
#include<conio.h>
void main()
{
int i,l,p=1;
clrscr();
for(i=1;i<=5;i++)
{
if(i%2!=0)
{
for(l=1;l<=5;l++)
printf("%4d",l*i);
}
else
{
for(l=1;l<=5;l++)
printf("%4d",l*i);
}
printf("\n");
}
getch();
}
write this code in Turbo c and see what will be output
#include<stdio.h>
#include<conio.h>
void main()
{
int q,i,j,s,t=9,p;
clrscr();
for(i=1;i<=5;i++)
{
for(q=1;q<=32;q++)
printf(" ");
for(j=i;j<5;j++)
printf(" ");
for(s=t,p=1;s<=9;s++,p++)
printf("%d",p);
printf("\n");
t-=2;
}
t=3;
for(i=4;i>=1;i--)
{
for(q=1;q<=32;q++)
printf(" ");
for(j=i;j<5;j++)
printf(" ");
for(s=t,p=1;s<=9;s++,p++)
printf("%d",p);
printf("\n");
t+=2;
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,l,p=1;
clrscr();
for(i=1;i<=5;i++)
{
if(i%2!=0)
{
for(l=1;l<=5;l++)
printf("%4d",l*i);
}
else
{
for(l=1;l<=5;l++)
printf("%4d",l*i);
}
printf("\n");
}
getch();
}
write this code in Turbo c and see what will be output
#include<stdio.h>
#include<conio.h>
void main()
{
int q,i,j,s,t=9,p;
clrscr();
for(i=1;i<=5;i++)
{
for(q=1;q<=32;q++)
printf(" ");
for(j=i;j<5;j++)
printf(" ");
for(s=t,p=1;s<=9;s++,p++)
printf("%d",p);
printf("\n");
t-=2;
}
t=3;
for(i=4;i>=1;i--)
{
for(q=1;q<=32;q++)
printf(" ");
for(j=i;j<5;j++)
printf(" ");
for(s=t,p=1;s<=9;s++,p++)
printf("%d",p);
printf("\n");
t+=2;
}
getch();
}
0 comments: