C Program to Print Alphabet ‘A’ using Stars for given numbers

Write a program to print the alphabet ‘A’ using stars for given N

Input Format
The input contains the integer value N

Output Format
Print  the alphabet ‘A’ 

Constraint
4<=N<=10Sample Input 1

4

Sample Output 1

 * 
* *
***
* *

Sample Input 2

7

Sample Output 2

 ** 
*  *
*  *
****
*  *
*  *
*  *

Sample Input 3

10

Sample Output 3

 **** 
*    *
*    *
*    *
*    *
******
*    *
*    *
*    *
*    *

Code:

#include<stdio.h> int main() { int n; scanf("%d",&n); int w=(n/2)+1; int f=(n/2)-1; int m=f+2; printf(" "); for(int i=0;i<f;i++) printf("*"); printf(" \n"); for(int i =1;i<n;i++) { for(int j =0;j<w;j++) { if(j == 0) printf("*"); else if(j == w-1) printf("*"); else if (i == m-1) { for(int l=0;l<w-1;l++) { printf("*"); } break; } else printf(" "); } printf("\n"); } }
Code language: C/AL (cal)

Leave a Comment