What is pattern programming? Learn how to create different patterns using for loop.
- 034. Write a program to print following outputs in C language
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#include<stdio.h> #include<conio.h> main() { int i,j,n; clrscr(); printf("Enter number : "); scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { printf("*"); } printf("\n"); } getch(); }
- 035. Write a program to print following outputs in C language
* * * * * * * * * * * * * * *
#include<stdio.h> #include<conio.h> main() { int i,j,n; clrscr(); printf("Enter number : "); scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=i;j++) { printf("*"); } printf("\n"); } getch(); }
- 036. Write a program to print following outputs in C language
* * * * * * * * * * * * * * *
#include<stdio.h> #include<conio.h> main() { int i,j,n; clrscr(); printf("Enter number : "); scanf("%d",&n); for(i=n;i>=1;i--) { for(j=1;j<=i;j++) { printf("*"); } printf("\n"); } getch(); }
- 037. Write a program to print following outputs in C language
* * * * * * * * * * * * * * *
#include<stdio.h> #include<conio.h> main() { int i,j,k,n; clrscr(); printf("Enter number : "); scanf("%d",&n); for(i=1;i<=n;i++) { for(k=1;k<i;k++) { printf(" "); } for(j=i;j<=n;j++) { printf("*"); } printf("\n"); } getch(); }
- 038. Write a program to print following outputs in C language
* * * * * * * * * * * * * * *
#include<stdio.h> #include<conio.h> main() { int i,j,k,n; clrscr(); printf("Enter number : "); scanf("%d",&n); for(i=n;i>=1;i--) { for(k=1;k<=(n-i);k++) { printf(" "); } for(j=1;j<=i;j++) { printf("*"); } printf("\n"); } getch(); }
- 039. Write a program to print following outputs in C language
* * * * * * * * * * * * * * * * * * * * * * * * *
#include<stdio.h> #include<conio.h> main() { int i,j,k,n; clrscr(); printf("Enter number : "); scanf("%d",&n); for(i=1;i<=n;i++) { for(k=1;k<=(n-i);k++) { printf(" "); } for(j=1;j<=i;j++) { printf("*"); } for(j=2;j<=i;j++) { printf("*"); } printf("\n"); } getch(); }
- 040. Write a program to print following outputs in C language
* * * * * * * * * * * * * * * * * * * * * * * * *
#include<stdio.h> #include<conio.h> main() { int i,j,k,n; clrscr(); printf("Enter number : "); scanf("%d",&n); for(i=n;i>=1;i--) { for(k=1;k<=(n-i);k++) { printf(" "); } for(j=1;j<=i;j++) { printf("*"); } for(j=2;j<=i;j++) { printf("*"); } printf("\n"); } getch(); }
- 041. Write a program to print following outputs in C language
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#include<stdio.h> #include<conio.h> main() { int i,j,k,n; clrscr(); printf("Enter number : "); scanf("%d",&n); for(i=1;i<=n;i++) { for(k=1;k<=(n-i);k++) { printf(" "); } for(j=1;j<=i;j++) { printf("*"); } for(j=2;j<=i;j++) { printf("*"); } printf("\n"); } for(i=n-1;i>=1;i--) { for(k=1;k<=(n-i);k++) { printf(" "); } for(j=1;j<=i;j++) { printf("*"); } for(j=2;j<=i;j++) { printf("*"); } printf("\n"); } getch(); }
- 042. Write a program to print following outputs in C language
1 12 123 1234
#include<stdio.h> #include<conio.h> main() { int i,j,k,n; clrscr(); printf("Enter number : "); scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=i;j++) printf("%d",j); printf("\n"); } getch(); }
- 043. Write a program to print following outputs in C language
1 22 333 4444
#include<stdio.h> #include<conio.h> main() { int i,j,k,n; clrscr(); printf("Enter number : "); scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=i;j++) printf("%d",i); printf("\n"); } getch(); }
- 044. Write a program to print following outputs in C language
A BBB CCCCC DDDDDDD
#include<stdio.h> #include<conio.h> main() { int i,j,k,n; clrscr(); printf("Enter number : "); scanf("%d",&n); //ASCII Code for 'A' is 65 for(i=1;i<=n;i++) { for(k=1;k<=(n-i);k++) { printf(" "); } for(j=1;j<=i;j++) { printf("%c",64+i); } for(j=2;j<=i;j++) { printf("%c",64+i); } printf("\n"); } getch(); }
- 045. Write a program to print following outputs in C language
ABCDEEDCBA ABCD DCBA ABC CBA AB BA A A
#include<stdio.h> #include<conio.h> main() { int i,n,j,k; clrscr(); printf("Enter number........"); scanf("%d",&n); for(i=n-1;i>=0;i--) { for(j=0;j<=i;j++) printf("%c",65+j); for(k=1;k<(n-i);k++) printf(" "); for(j=i;j>=0;j--) printf("%c",65+j); printf("\n"); } getch(); }
- 046. Write a program to print following outputs in C language
1 11 121 1231 12341 123451
#include<stdio.h> #include<conio.h> main() { int i,j,n; clrscr(); printf("Enter number..."); scanf("%d",&n); for(i=0;i<=n;i++) { for(j=1;j<=i;j++) { printf("%d",j); } printf("1\n"); } getch(); }