Course Details

Field of Study: Computer Science and Engineering
Course Name: C Programming
Course Description: C programming code to display asterisk in X pattern where the length of X is given by n

Code
#include<conio.h>
#include<stdio.h>
void main()
{
int n,i,j;
clrscr();
printf(“Enter the value of n”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
printf(“\n”);
for(j=1;j<=n;j++)
{
if((i==j)||(i+j==(n+1)))
printf(“*”);
else
printf(” “) ;
}
}
getch();
}

Output for n=7 is shown below
IMG_0298


HameroHa

Hameroha is the official agent for this website (hameroha.com). If you want to buy/sell cars or any other properties, you can directly contact us with phone numbers available on this profile.

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *