Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Patterns #46

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions patterns/Character Pattern.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*AAAAA
BBBB
CCC
DD
E */
#include<stdio.h>
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;
}
}
22 changes: 22 additions & 0 deletions patterns/Reverse number pattern.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*This is a program to print following pattern.
12345
1234
123
12
1 */
#include<stdio.h>
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");
}
}
22 changes: 22 additions & 0 deletions patterns/number pattern.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*This is a program to print following pattern.
1
12
123
1234
12345 */
#include<stdio.h>
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");
}
}
26 changes: 26 additions & 0 deletions patterns/piramid.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*This is a programe for following star pattern.
*
* *
* * *
* * * * */
#include<stdio.h>
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");

}
}