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();
}
0 Comments