Here is the code for the C program to print the star formation of a hollow square. The program will input an integer value from the user and print the hollow star formations.
Here is the code.
Here is the sample output.
As can be seen in the output above, for the user input, the hollow star square will be formed. The key to understand the logic of the code is as follows.
The outerloop controls the number of lines and inner loop controls the number of stars.
Here is the code.
#include “stdio.h” int main() { int num,i,j; printf("Please enter a number to print the hollow star formation \n"); scanf("%d", &num); for(i=0;i<num;i++) { for(j=0;j<num;j++) { if(i==0 || i==num-1) { printf("*"); } else if(j==0 || j==num-1) { printf("*"); } else { printf(" "); // space is printed .. } } printf("\n"); } return 0; } |
Here is the sample output.
As can be seen in the output above, for the user input, the hollow star square will be formed. The key to understand the logic of the code is as follows.
The outerloop controls the number of lines and inner loop controls the number of stars.
Thank you soo much!!
ReplyDeleteYou've helped me a lot!! >3<
haha..
This comment has been removed by the author.
ReplyDeleteThank you so much! Really helpful for newbie programmers up to this day :)
ReplyDeletei want to code a rectangle of stars within a rectangle of stars can anybody help me thanks?
ReplyDeletePlease help me in coding of diamond with hollow center and many stars around the center
ReplyDeleteJava jobs are becoming more plentiful as the use of this software is more and more common online. Those skilled in java applications are in demand now by telecommuting companies. These jobs allow you to work from home with java software. See more assignment programming
ReplyDelete
ReplyDeleteI want these code in Java Can you give me code ?
#
###
#####
##
#
How to Write this program to Print Star Pattern in Java
Really Nice Post to Print Star Pattern in Java Yesterday I visit this blog and i was found lots of helpful information from your side thanks for sharing updated and New Technology related Post.
ReplyDeleteIn Chau Long We are proud to bring our customers the products of printing paper bags, printing paper boxes, printing catalogs, printing directories, printing leaflets, high quality printing leaflets, reasonable prices and Meet all requirements for the customer's process set.
ReplyDeletein ấn tại bắc ninh
Công ty in offset tại Bắc Ninh
in offset hà nội
in offset giá rẻ hà nội
This comment has been removed by the author.
ReplyDeleteThank you very much! Really helpful for programmers c programming assignment help
ReplyDelete