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.

Check Voting Eligibility in C Program (Step-by-Step Guide)

                     C Program  

C Program to Check Whether a People is Eligible to Vote or Not



Write a C Program to Check Age Eligibility for Voting

Example  :-

#include<stdio.h>
 #include<conio.h>
int main()
{
int age;
clrscr();
 printf("enter your age :-");
scanf("%d", &age);
if(age>=18)
{
printf("you are eligible to vote");
}
else
{
printf("you are not eligible for vote");
}
getch();
return 0;
}


C Program to Check Whether a People is Eligible to Vote or Not  

Explain Program

Step :1

      #include <stdio.h>

use input/output library for functions like printf() and scanf().

Step :2

     int main() {

  int main is use Start of the main function the execution.

Step :3

int age;

  • Declares an integer variable named age.
  •  used to store the age input by the user

Step :4

printf("enter your age :-");

  • Displays the message “enter your age :-” on the screen.
  •  user to enter their age.

Step :5

scanf("%d", &age);

  • Reads an integer input from the user.
  • %d tells scanf to expect an integer.
  • &age is the address of the variable age, where the entered value will be stored.

Step :6

if (age >= 18)

  •  user's age  greater than or equal to 18.
  • If true, it mean the person is eligible to vote.

Step :7

{

 printf("you are eligible to vote"); 

}

  • If the condition is true (age >= 18), this message is printed.

Step :8

else { 

printf("you are not eligible for vote");

 }

  • this  condition is use  false (ie. age < 18) this block run.
  • It print the message “you are not eligible for vote”


 Program Output 

enter your age :- 18 
you are eligible to vote 

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