Print Boat Pattern Using For Loop In C Program
Program to print boat pattern of n rows using for loop.
Example : pgm.c
#include<string.h> int main(){ int i,j,n; printf("\n Enter the limit:"); scanf("%d",&n); for(i=0;i<n;i++){ for(j=0;j<n;j++){ printf(" "); } for(j=0;j<i;j++){ printf("*"); } printf("\n"); } for(i=0;i<=n/2;i++){ for(j=0;j<i;j++){ printf(" "); } for(j=0;j<n-i;j++){ printf("*"); } for(j=0;j<n+n;j++){ printf("*"); } for(j=0;j<n-i;j++){ printf("*"); } printf("\n"); } return 0; }
Output:
Enter the limit: 10
* ** *** **** ***** ****** ******* ******** ********* **************************************** ************************************** ************************************ ********************************** ******************************** ******************************