Conditional Rendering in React Complete Guide with Examples 2026

Image
  Conditional Rendering in React Conditional Rendering is one of the most useful concepts in React. It means showing different content on the screen depending on a condition. For example: If a user is logged in → show Logout If a user is not logged in → show Login If a student has passed → show Congratulations If a product is available → show Buy Now If data is loading → show Loading... React does not have a separate if rendering tag. Instead, we use normal JavaScript conditions such as if, the ternary operator, &&, and switch to decide what should appear in the UI.

C Program to Print Hollow Square Star Pattern

C Program  Pattern

C Program to Print Hollow Square  Star Pattern



C Program to Print Hollow Square  Star Pattern 
Example



#include <stdio.h>

int main()
{
   int i, j, N;

 
   printf("Enter number of rows: ");
   scanf("%d", &N);

   for(i=1; i<=N; i++)
   {
   
       for(j=1; j<=N; j++)
       {
           if(i==1 || i==N || j==1 || j==N)
           {
             
               printf("*");
           }
           else
           {
               printf(" ");
           }
       }

     
       printf("\n");
   }

   return 0;
}

C Program to Print Hollow Square  Star Pattern
Explain Program

Step :1

#include <stdio.h>

Standards Input Output library,  printf and scanf. 

Step :2

int main()

 entry point of the program.

i for iterating through rows,

 j for iterating through columns,

 N for the size of the square (number of rows and columns). 

Step :3

printf("Enter number of rows: ");

scanf("%d", &N);

 user to input a number (N), which defines the dimension of the square.

square will have N rows and N columns.

 Step :4

Outer Loop: 
Rows
for(i=1; i<=N; i++)
loop run from 1 to N (inclusive) to handlerow.

Step :5

Inner Loop:

 Columns

for(j=1; j<=N; j++)

 loop runs for each column within a row (again from 1 to N).

Step :6

Logic to Print the Border

if(i==1 || i==N || j==1 || j==N)

condition check current cell border of the square:

 First row: i == 1

 Last row: i == N

First column: j == 1

 Last column: j == N

 condition is true:

Step :7

printf("*");

Print an asterisk (*).

Step :8

printf(" ");

Print a space ( ) to create the hollow center.

Step :9

printf("\n");

After finishing row, move to the next line.

Step :10

 return 0;

 program finished successfully

C Program to Print Hollow Square  Star Pattern
OutPut :-

C Program to Print Hollow Square  Star Pattern

Related Post :-



Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

HTML Input Type Submit Syntax and Example