diff --git a/patterns/Character Pattern.c b/patterns/Character Pattern.c new file mode 100644 index 0000000..fae30bd --- /dev/null +++ b/patterns/Character Pattern.c @@ -0,0 +1,32 @@ +/*AAAAA + BBBB + CCC + DD + E */ +#include +void main() +{ + int n,x=65; + printf("Enter the number of rows which should be less than 26.\n"); + start: + scanf("%d",&n); + + if (n<27) + { + for(int i = n; i > 0;i--) + { + for(int j = i;j > 0; j--) + { + printf("%c",x); + } + x +=1; + printf("\n"); + } + } + else + { + printf("Invalid input.\n"); + printf("Enter the number of rows again.\n"); + goto start; + } +} diff --git a/patterns/Reverse number pattern.c b/patterns/Reverse number pattern.c new file mode 100644 index 0000000..51701c6 --- /dev/null +++ b/patterns/Reverse number pattern.c @@ -0,0 +1,22 @@ +/*This is a program to print following pattern. +12345 +1234 +123 +12 +1 */ +#include +void main() +{ + int n; + printf("Enter the number of rows.\n"); + scanf("%d",&n); + + for(int i = n;i > 0;i--) + { + for(int j = 1;j <= i;j++) + { + printf("%d",j); + } + printf("\n"); + } +} diff --git a/patterns/number pattern.c b/patterns/number pattern.c new file mode 100644 index 0000000..f71aaee --- /dev/null +++ b/patterns/number pattern.c @@ -0,0 +1,22 @@ +/*This is a program to print following pattern. +1 +12 +123 +1234 +12345 */ +#include +void main() +{ + int n; + printf("Enter the number of rows.\n"); + scanf("%d",&n); + + for(int i = 1;i <= n;i++) + { + for(int j = 1;j <= i;j++) + { + printf("%d",j); + } + printf("\n"); + } +} diff --git a/patterns/piramid.c b/patterns/piramid.c new file mode 100644 index 0000000..ff66251 --- /dev/null +++ b/patterns/piramid.c @@ -0,0 +1,26 @@ +/*This is a programe for following star pattern. + * + * * + * * * + * * * * */ +#include +void main() +{ + int n; + printf("Enter the number of rows.\n"); + scanf("%d",&n); + + for(int i = 1;i <= n; i ++) + { + for(int j = 0; j < n-i; j ++) + { + printf(" "); + } + for(int j = 0; j < i; j ++) + { + printf("* "); + } + printf("\n"); + + } +}