Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,906 questions

51,838 answers

573 users

How to print hollow rectangle star pattern in C

1 Answer

0 votes
#include <stdio.h>

void print_hollow_rectangle(int total_stars) {
   for (int i = 1; i <= total_stars; i++) {
      for (int j = 1; j <= total_stars; j++) {
         if (i == 1 || i == total_stars || j == 1 || j == total_stars) {
            printf("*");
         }
         else {
            printf(" ");
         }
      }
      printf("\n");
   } 
}
 
int main() {
   print_hollow_rectangle(7);
   
   return 0;
}
 
 
 
 
/*
run:
   
*******
*     *
*     *
*     *
*     *
*     *
*******
   
*/

 



answered Sep 22, 2021 by avibootz
edited Sep 11, 2023 by avibootz

Related questions

1 answer 121 views
1 answer 73 views
1 answer 90 views
1 answer 145 views
145 views asked Sep 14, 2023 by avibootz
1 answer 132 views
...