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 prime or Not prime

                                      C Program 



 C Program to Check Number is prime or Not prime

Examples :-



#include<stdio.h>
#include<conio.h>
void main()
{
int a, i, flag=0;
printf("enter a positive integer");
scanf("%d", &a);
if(a==0||a==1)
flag=1;
for(i=2;i<=a/2;i++)
{
if(a%i==0)
{
flag =1;
break;
}
}
if (flag==0)
printf("%d is prime number ", a);
else
printf("%d is not prime number",a);
getch();
return 0;
}




C Program to Check Number is prime or Not prime

Explain Program

Step :1

#include <stdio.h>

 Standard Input Output library, which is required for functions like printf() and scanf().

Step :2

void main()

This is the main function, where program execution starts.

Step :3

int a, i, flag = 0;

 stores the number  a, b entered by the user.

Step :4

printf ("enter a positive integer");

scanf ("%d", &a);

 user to enter a number.

 scanf () reads the input and stores it in variable a.

Step :5

if (a == 0 || a == 1)

    flag=1;

0 and 1 are not prime numbers by definition.

Step :6

for (i = 2; i <= a / 2; i++)

{

    if (a % i == 0)

    {

        flag = 1;

        break;

    }

}

loop check if any number between 2 and a/2 divides a completely

Step :7

if (flag == 0)

    printf("%d is prime number ", a);

else

    printf("%d is not prime number", a);

If no divisor was found (flag is still 0), the number is prime.


Output 

 enter a positive integer 133
   133 is not prime number


Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

HTML Input Type Submit Syntax and Example