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 check number is even or odd use if else

                          c program

c program to check number is even or odd

Examples :-


// even or odd program if else
//if else statement statement only allows
// program to execute one block of code if a check condition
// is true than execute the block or condition is false than exite the block
// of code.

#include<stdio.h>

int main()
{
int number= 0;

printf("enter a number");
scanf("%d",&number);
if(number %2 ==0 )
{
printf("%d is even");
}
else
{
printf("%d is odd");
}

return 0;
}


 c program to check number is even or odd use if else

Explain Program

Step :1

#include <stdio.h>

 input-output use printf() & scanf() function.

Step :2

int main()

 point of the C program. All execution .

Step :3

  • printf("enter a number");
  • Prints a prompt for the user. You could add a newline ("\n") for cleanliness.

Step :4

  • scanf("%d", &number);
  • Reads an integer from the user and stores it in number. The & gives the variable’s memory address.

Step :5

if (number % 2 == 0) {

    printf("%d is even");

} else {

    printf("%d is odd");

}

Step :6

  • If (number % 2) == 0, there's no remainder, so it's even.
  • Otherwise, it's odd.

Step :7

if (number & 1)   // true if odd (LSB is 1)

else              // even (LSB is 0)

Step :8

printf("%d is even\n", number);

Add a newline to output for readability

 c program to check number is even or odd use if else

Output 

enter a number  
7 is Odd


Related post :-

c program add two integer number

left pascal star pattern in php

Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

HTML Input Type Submit Syntax and Example