HTML Tutorial || Networking Assignment || Computer Full Forms || Ms-Office Shortcut Keys || Ms-Office Notes || Number System Notes || Internet Assignment
JavaScript Tutorial || CSS Tutorial || Operating System Notes || History of Computer Assignment || Netwoking Notes || Computer Fundamentals Notes

C Program to Printing a Pattern ?


Q:- Write a C Program to Print Pattern :
 1.    1          2       3          4
         1          2       3          4
         1          2       3          4
         1          2       3          4
       Input
         #include<stdio.h>
         #include<conio.h>
         main()
  {
int i,j;
clrscr();
for(i=1;i<=4;i++)
{
for(j=1;j<=4;j++)
{
printf(“%d\t”,j);
}
printf(“\n”);
}
getch();
    }



2.     4          3       2          1
         4          3       2          1 
         4          3       2          1
         4          3       2          1
        Input
          #include<stdio.h>
          #include<conio.h>
          main()
  {
int i,j;
clrscr();
for(i=4;i>=0;i--)
{
for(j=4;j>=0;j--)
{
printf(“d\t”,j);
}
printf(“\n”);
}
getch();
    }
3.     1          1       1          1
         2          2       2          2
         3          3       3          3
         4          4       4          4
       Input
         #include<stdio.h>
         #include<conio.h>
         main()
   {
int i,j;
clrscr();
for(i=1;i<=4;i++)
{
for(j=1;j<=4;j++)
{
printf(“%d\t”,i);
}
printf(“:\n”);
}
getch();
    }



4.     1
         1          2      
         1          2       3
         1          2       3          4
       Input
         #include<stdio.h>
         #include<conio.h>
         main()
    {
int i,j;
clrscr();
for(i=1;i<=4;i++)
{
for(j=1;j<=i;j++)
{
printf(“%d\t”,j);
}
printf(“\n”);
}
getch();
     }
5.                         1
                     3       3          3
         5          5       5          5          5
       Input
         #include<stdio.h>
         #include<conio.h>
        main()
  {
int i,j,m;
clrscr();
for(i=1;i<=5;i++)
{
for(m=5;m>=I;m--)
{
printf(“ “);
}
for(j=1;j<=I;j++)
{
printf(“ %d”,i);
}
Printf(“\n”);
}
getch();
     }




6.     4          4       4          4
         3          3       3
         2          2
         1
       Input
         #include<stdio.h>
         #include<conio.h>
         main()
   {
int i,j;
clrscr();
for(i=4;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf(“%d\t”<i);
}
printf(“\n”);
}
etch();
       }