Hello there!
Welcome to our blog in this tutorial we will see how to write code to print alphabet A pattern in C language using only two loops in a simple way.
before that once we will see the algorithm of the program. Repeat an algorithm is nothing but steps involved in the process of development of the program, in this program, there are 11 steps involved
Algorithm of A pattern program
Let's see the steps
step 1: start
step 2: initialize variables p,q,a,b,c,d.
step 3: read a from user.
step 4: b=a.
step 5 : c=a.
step 6: d=(a\2)+1.
step 7:repaet the step untill p=a.
step 7.1:Repeat the step until q=c.
step 7.2: if q=b or q=b.
print *.
Else if p=d and q>b.
print *.
Else print one space.
step 8:b=b-1.
step 9: c=c+1.
step 10: print new line
step 11: stop.
By observing this algorithm we get awareness about the program how it will work step by step. for a better understanding of the program, let's see the flow chart of the program. i hope that will give more knowledge about the program.
Flowchart of program
![]() |
| flow chart of A pattern program |
finally its program time lets take a look
program
#include#include int main() { int p,q,a,b,c,d; printf("enter a number :"); scanf("%d",&a); b=a; c=a; d=(a/2)+1; for(p=1;p<=a;p++) { for(q=1;q<=c;q++) { if(q==b||q==c) {printf("*");} else if(p==d&&q>b) {printf("*");} else{printf(" ");} } b--;c++; printf("\n"); } getch(); return 0; }
Output :
ok, If you want more programs then please allow notification to my website.
if you have any doubt or if you want any program please comment we will do it for you
Thank you for visiting.




0 Comments