Tuesday, October 21, 2014

Print B patterns with C language




                                                      

#include<stdio.h>
#include<conio.h>

void main()
{
                        int i,n,j;
                        printf("\t enter value of n=");
                        scanf("%d",&n);
      printf("\n\n");
                        for(i=0;i<n;i++)
                        {
                                    for(j=0;j<n;j++)
                                    {
                                                if(i==0||j==1||j==n-1||i==n-1||i==n/2)
                                                {
                                                            printf("*");
                                                }
                                                else
                                                {
                                                            printf(" ");
                                                }
                                    }
                                    printf("\n");
                        }
}

No comments:

Post a Comment