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.

armstrong number program in php

Armstrong number PHP Program

Armstrong number

Armstrong number

 1] one whose value is equal to the sum of the cubes of its digits.

  2]  There are Four 3digit Armstrong number - 153, 370, 370 , 407, 1634, 8208,  etc

Armstrong number program in php

Example :-

<?php
$num=150;
$total=0;
$x=$num;
while($x!=0)
{
    $rem=$x%10;
    $total=$total+$rem*$rem*$rem;
    $x=$x/10;
}
if($num==$total)
{
    echo "Yes it an Armstrong number";
}
else
{
    echo "Not an Armstrong Number";
}
?>

armstrong number program in php
Output :-

armstrong number check

armstrong number program using form php

Example :-



<form method="post">
    Enter number
    <input type="number" name="number"><br><br>
    <input type="submit" value="submit">
</form>
<?php
if($_POST)
{
    $num = $_POST['number'];
    $a=$num;
    $sum=0;
    while($a!= 0)
    {
        $rem = $a%10;
        $sum=$sum+($rem*$rem*$rem);
        $a =$a/10;
        }
        if($num==$sum)
         {
            echo " $num Yes Number is Armstrong Number";
         }
         else
         {
            echo " $num  Not Number is Armstrong Number";

         }
         }
    ?>

armstrong number program using form  php

Output :-

armstrong number check


Related Articles:-

php program to print alphabet pattern P

php program to print alphabet pattern C

Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

HTML Input Type Submit Syntax and Example