Q1. Write Program To Print Following Pattern 1 12 123

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

Q1.

Write program to print following pattern


1
12
123

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j;
for(i=1;i<=3;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
getch();
return 0;
}

Q2. Write program to print following pattern


1
22
333

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j;
for(i=1;i<=3;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",i);
}
printf("\n");
}
getch();
return 0;
}
Q3. Write program to print following pattern
1
22
333

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j;
for(i=1;i<=3;i++)
{
for(j=3;j>i;j--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("%d ",i);
}
printf("\n");
}
getch();
return 0;
}

Q4. Write program to print following pattern


1
23
456

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,k;
k=1;
for(i=1;i<4;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",k++);
}
printf("\n");
}
getch();
return 0;
}

Q5. Write program to print following pattern


1
12
123

#include<stdio.h>
#include<conio.h>
int main()
{
int s, i, j;
for(i=1;i<=3;i++)
{
for(s=3;s>i;s--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("%d", j);
}
printf("\n");
}
getch();
return 0;
}

Q6. Write program to print following pattern


1
21
321

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j;
for(i=1;i<=3;i++)
{
for(j=i;j>=1;j--)
{
printf("%d",j);
}
printf("\n");
}
getch();
return 0;
}

Q7. Write program to print following pattern


1
121
12321

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,s,r;
for(i=1;i<=3;i++)
{
for(s=3-i;s>=1;s--)
printf(" ");
for(j=1;j<=i;j++)
printf("%d",j);
for(r=i-1;r>=1;r--)
printf("%d",r);
printf("\n");
}
getch();
return 0;
}

Q8. Write program to print following pattern


123
12
1

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,s;
for(i=3;i>=1;i--)
{
for(j=1;j<=i;j++)
printf("%d",j);
printf("\n");
}
getch();
return 0;
}

Q9. Write program to print following pattern


32123
323
3

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,s,r;
for(i=1;i<=3;i++)
{
for(s=i-1;s>=1;s--)
printf(" ");
for(j=3;j>=i;j--)
printf("%d",j);
for(r=i+1;r<=3;r++)
printf("%d",r);
printf("\n");
}
getch();
return 0;
}

Q10. Write program to print following pattern


1
222
33333

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,s;
for(i=1;i<=3;i++)
{
for(s=3-i;s>=1;s--)
printf(" ");
for(j=1;j<=2*i-1;j++)
printf("%d",i);
printf("\n");
}
getch();
return 0;
}

Q11. Write program to print following pattern


0
101
21012

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,s,r;
for(i=1;i<=3;i++)
{
for(s=3-i;s>=1;s--)
printf(" ");
for(j=i-1;j>=0;j--)
printf("%d",j);
for(r=1;r<=i-1;r++)
printf("%d",r);
printf("\n");
}
getch();
return 0;
}

Q12. Write program to print following pattern


zyxyz
zyz
z

#include<stdio.h>
#include<conio.h>
int main()
{
int i,s;
char j,r;
for(i=1;i<=3;i++)
{
for(s=i-1;s>=1;s--)
printf(" ");
for(j=3;j>=i;j--)
printf("%c",j+119);
for(r=i+1;r<=3;r++)
printf("%c",r+119);
printf("\n");
}
getch();
return 0;
}

Q13. Write program to print following pattern


a
ab
abc

#include<stdio.h>
#include<conio.h>
int main()
{
int i;
char j;
for(i=1;i<=3;i++)
{
for(j=1;j<=i;j++)
printf("%c",j+96);
printf("\n");
}
getch();
return 0;
}

Q14. Write program to print following pattern


*
**
***
****

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,s;
for(i=1;i<=4;i++)
{
for(s=1;s<=4-i;s++)
printf(" ");
for(j=1;j<=i;j++)
printf("* ");
printf("\n");
}
getch();
return 0;
}

Q15. Write program to print following pattern


abc
ab
a

#include<stdio.h>
#include<conio.h>
int main()
{
int i;
char j;
for(i=3;i>=1;i--)
{
for(j=1;j<=i;j++)
printf("%c",j+96);
printf("\n");
}
getch();
return 0;
}

Q16. Write program to print following pattern


1
121
12121

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,s,n=1;
for(i=1;i<=3;i++)
{
for(s=i;s<3;s++)
printf(" ");
for(j=1;j<=n;j++)
{
if(j%2==0)
printf("2");
else
printf("1");
}
n=n+2;
printf("\n");
}
getch();
return 0;
}

Q17. Write program to print following pattern


321
32
3

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j;
for(i=1;i<=3;i++)
{
for(j=3;j>=i;j--)
printf("%d",j);
printf("\n");
}
getch();
return 0;
}

Q18. Write program to print following pattern


abc
bc
c

#include<stdio.h>
#include<conio.h>
int main()
{
int i,s;
char j;
for(i=1;i<=3;i++)
{
for(s=i-1;s>0;s--)
printf(" ");
for(j=i;j<=3;j++)
printf("%c ",j+96);
printf("\n");
}
getch();
return 0;
}

Q19. Write program to print following pattern


321
21
1

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j;
for(i=3;i>=1;i--)
{
for(j=i;j>=1;j--)
printf("%d",j);
printf("\n");
}
getch();
return 0;
}

Q20. Write program to print following pattern


123
12
1

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j;
for(i=3;i>=1;i--)
{
for(j=1;j<=i;j++)
printf("%d",j);
printf("\n");
}
getch();
return 0;
}

Q21. Write program to print following pattern


ABCDEFGHIJKLMNOPQRST
ACEGIKMOQS
ADGJMPS
AEIMQ

#include<stdio.h>
#include<conio.h>
int main()
{
int i;
char j;
for(i=1;i<=4;i++)
{
for(j=1;j<=20;j=j+i)
printf("%c",j+64);
printf("\n");
}
getch();
return 0;
}

Q22. Write program to print following pattern


ABCDEBCDECDEDEE
ABCDEBCDECDEDE
ABCDEBCDECDE
ABCDEBCDE
ABCDE

#include<stdio.h>
#include<conio.h>
int main()
{
int i,n,j;
printf("Enter number: ");
scanf("%d",&n);
char k;
for(i=1;i<=n;i++)
{
for(j=1;j<=n+1-i;j++)
{
for(k=j;k<=n;k++)
printf("%c",k+64);

}
printf("\n");
}
getch();
return 0;
}

You might also like