Advertisement
Aniket_Goku

task1

Jun 12th, 2021
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.58 KB | None | 0 0
  1. <?php
  2.     $i=0;
  3.     $j=0;
  4.     $rev=0;
  5.     if(isset($_POST['sub']))
  6.     {
  7.         $a=0;
  8.        
  9.         $s=$_POST['op'];
  10.         if($s=='Reverse')
  11.         {
  12.             $temp=$_POST['no'];
  13.            
  14.             while($temp!=0)
  15.             {
  16.                 $a=$temp%10;
  17.                 $rev=($rev*10)+$a;
  18.                 $temp=intdiv($temp,10);
  19.                
  20.             }
  21.            
  22.            
  23.         }
  24.         else if($s=='Palindrom')
  25.         {
  26.             $temp=$_POST['no'];
  27.            
  28.             while($temp!=0)
  29.             {
  30.                 $a=$temp%10;
  31.                 $rev=($rev*10)+$a;
  32.                 $temp=intdiv($temp,10);
  33.                
  34.             }
  35.             if($rev==$_POST['no'])
  36.             {
  37.                 $rev= $_POST['no']." is an Palindrom no";
  38.             }
  39.             else if($rev!=$_POST['no'])
  40.             {
  41.                 $rev=$_POST['no']." is NOT Palindrom no";
  42.             }
  43.             else
  44.             {
  45.                 $rev=0;
  46.             }
  47.         }
  48.         else if($s=='Armstrong')
  49.         {
  50.             $t=$_POST['no'];
  51.             $digit=0;
  52.             $ans=0;
  53.             while($t!=0)
  54.             {
  55.                     $digit++;
  56.                     $t=intdiv($t,10);
  57.             }
  58.            
  59.             $t=$_POST['no'];
  60.             while($t!=0)
  61.             {
  62.                 $mul=1;
  63.                 $a=$t%10;
  64.                 for($i=0;$i<$digit;$i++)
  65.                 {
  66.                     $mul*=$a;
  67.                 }
  68.                 $ans=$ans+$mul;
  69.                 $t=intdiv($t,10);
  70.             }
  71.             if($ans==$_POST['no'])
  72.             {
  73.                     $rev=$_POST['no']." is an armstrong no";
  74.             }
  75.             else if($ans!=$_POST['no'])
  76.             {
  77.                 $rev=$_POST['no']." is NOT an armstrong no";
  78.             }
  79.             else
  80.             {
  81.                     $rev=0;
  82.             }
  83.         }
  84.         else if($s=='Fibonaci')
  85.         {
  86.             $t=$_POST['no'];
  87.             $digit=0;
  88.             $ans=0;
  89.             while($t!=0)
  90.             {
  91.                     $digit++;
  92.                     $t=intdiv($t,10);
  93.             }
  94.             if($digit>1)
  95.             {
  96.                     $rev="Sigle digit needed[1-9]!";
  97.             }
  98.             else
  99.             {
  100.                 $t=$_POST['no'];
  101.                 if($t==1)
  102.                 {
  103.                     $rev="0 ";
  104.                 }
  105.                 else if($t==2)
  106.                 {
  107.                     $rev="0 1 ";
  108.                 }
  109.                 else if($t>2)
  110.                 {
  111.                     $rev="0 1 ";
  112.                     $no1=0;
  113.                     $no2=1;
  114.                     $no3=0;
  115.                     $i=0;
  116.                     for($i=2;$i<$_POST['no'];$i++)
  117.                     {
  118.                         $no3=$no1+$no2;
  119.                         $rev=$rev.$no3." ";
  120.                         $no1=$no2;
  121.                         $no2=$no3;
  122.                     }
  123.                    
  124.                 }
  125.                 else
  126.                 {
  127.                     $rev="Nagative value will not Accepted";
  128.                 }
  129.             }
  130.         }
  131.         else if($s=='Factorial')
  132.         {
  133.             $t=$_POST['no'];
  134.             $digit=0;
  135.             $ans=0;
  136.             $rev=0;
  137.        
  138.             while($t!=0)
  139.             {
  140.                     $digit++;
  141.                     $t=intdiv($t,10);
  142.             }
  143.             if($digit>1)
  144.             {
  145.                     $rev="Sigle digit needed[1-9]!";
  146.             }
  147.             else
  148.             {
  149.                 $t=$_POST['no'];
  150.                
  151.                 if($t>0)
  152.                 {
  153.                 $rev=$_POST['no']."! => ";
  154.                     $ans=1;
  155.                     $i=0;
  156.                     for($i=1;$i<=$_POST['no'];$i++)
  157.                     {
  158.                        
  159.                         $ans=$ans*$i;
  160.                        
  161.                     }
  162.                     $rev=$rev.$ans;
  163.                 }
  164.                 else
  165.                 {
  166.                     $rev="Nagative or zero value will not Accepted";
  167.                 }
  168.             }
  169.         }
  170.         else
  171.         {
  172.             $rev="SElect the opration";
  173.         }
  174.     }
  175.        
  176.    
  177. ?>
  178.  
  179. <html>
  180.    
  181.     <head>
  182.         <title>task - 1</title>
  183.     </head>
  184.    
  185.     <style>
  186.         body
  187.         {
  188.             background-image:url('backgrounds/66.jpg');
  189.             background-size:100%;
  190.             backdrop-filter:blur(4px);
  191.             margin:0;padding:0;height:100%;
  192.            
  193.         }
  194.         .l
  195.         {
  196.             background-color:black;
  197.             color:White;
  198.             font-size:30px;
  199.         }
  200.         .l1
  201.         {
  202.             //background-color:black;
  203.             color:White;
  204.             font-size:40px;
  205.             height:60px;
  206.             width:100%;
  207.             background-color:transparent;
  208.             border:0;
  209.             text-align:center;
  210.         }
  211.         h1
  212.         {
  213.             background-color:black;
  214.             color:White;
  215.             font-size:50px;
  216.             text-align:center;
  217.         }
  218.         td
  219.         {
  220.             width:50%;
  221.         }
  222.     </style>
  223.     <body>
  224.         <form name="f1" method="post">
  225.                 <h1>TASK - 1</h1>
  226.            
  227.                 <table border="0"  cellspacing="25"align="center" width="70%">
  228.                     <tr>
  229.                         <td align="right"><label class="l" > Enter the Number</label>
  230.                         </td>
  231.                         <td><input type="textbox" name="no" style="width:100%" class="l"placeholder="Enter here!!">
  232.                         </td>
  233.                     </tr>
  234.                     <tr>
  235.                         <td  style="vertical-align:top" align="right"><label class="l">Option</label></td>
  236.                         <td>
  237.                         <input type="radio" name="op" value="Reverse"class="l"><label class="l">Reverse</label><br><br>
  238.                         <input type="radio" name="op" value="Palindrom"class="l"><label class="l">Palindrom</label><br><br>
  239.                         <input type="radio" name="op" value="Armstrong"class="l"><label class="l">Armstrong</label><br><br>
  240.                         <input type="radio" name="op" value="Fibonaci"class="l"><label class="l">Fibonaci(single digit only)</label><br><br>
  241.                         <input type="radio" name="op" value="Factorial"class="l"><label class="l">factorial(single digit only)</label><br><br>
  242.                            
  243.                         </td>
  244.                        
  245.                     </tr>
  246.                     <tr>
  247.                         <td colspan="2" align="center">
  248.                            
  249.                             <input type="submit" name="sub" value="Ans" class="l" style="width:40%;height:50px">
  250.                            
  251.                         </td>
  252.                     </tr>
  253.                     <tr>
  254.                         <td colspan="2" align="center">
  255.                            
  256.                            
  257.                             <input type="text" name="report"  class="l1"readonly value="<?php echo $rev;?>">
  258.                         </td>
  259.                     </tr>
  260.                    
  261.                 </table>
  262.            
  263.         </form>
  264.     </body>
  265. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement