Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $i=0;
- $j=0;
- $rev=0;
- if(isset($_POST['sub']))
- {
- $a=0;
- $s=$_POST['op'];
- if($s=='Reverse')
- {
- $temp=$_POST['no'];
- while($temp!=0)
- {
- $a=$temp%10;
- $rev=($rev*10)+$a;
- $temp=intdiv($temp,10);
- }
- }
- else if($s=='Palindrom')
- {
- $temp=$_POST['no'];
- while($temp!=0)
- {
- $a=$temp%10;
- $rev=($rev*10)+$a;
- $temp=intdiv($temp,10);
- }
- if($rev==$_POST['no'])
- {
- $rev= $_POST['no']." is an Palindrom no";
- }
- else if($rev!=$_POST['no'])
- {
- $rev=$_POST['no']." is NOT Palindrom no";
- }
- else
- {
- $rev=0;
- }
- }
- else if($s=='Armstrong')
- {
- $t=$_POST['no'];
- $digit=0;
- $ans=0;
- while($t!=0)
- {
- $digit++;
- $t=intdiv($t,10);
- }
- $t=$_POST['no'];
- while($t!=0)
- {
- $mul=1;
- $a=$t%10;
- for($i=0;$i<$digit;$i++)
- {
- $mul*=$a;
- }
- $ans=$ans+$mul;
- $t=intdiv($t,10);
- }
- if($ans==$_POST['no'])
- {
- $rev=$_POST['no']." is an armstrong no";
- }
- else if($ans!=$_POST['no'])
- {
- $rev=$_POST['no']." is NOT an armstrong no";
- }
- else
- {
- $rev=0;
- }
- }
- else if($s=='Fibonaci')
- {
- $t=$_POST['no'];
- $digit=0;
- $ans=0;
- while($t!=0)
- {
- $digit++;
- $t=intdiv($t,10);
- }
- if($digit>1)
- {
- $rev="Sigle digit needed[1-9]!";
- }
- else
- {
- $t=$_POST['no'];
- if($t==1)
- {
- $rev="0 ";
- }
- else if($t==2)
- {
- $rev="0 1 ";
- }
- else if($t>2)
- {
- $rev="0 1 ";
- $no1=0;
- $no2=1;
- $no3=0;
- $i=0;
- for($i=2;$i<$_POST['no'];$i++)
- {
- $no3=$no1+$no2;
- $rev=$rev.$no3." ";
- $no1=$no2;
- $no2=$no3;
- }
- }
- else
- {
- $rev="Nagative value will not Accepted";
- }
- }
- }
- else if($s=='Factorial')
- {
- $t=$_POST['no'];
- $digit=0;
- $ans=0;
- $rev=0;
- while($t!=0)
- {
- $digit++;
- $t=intdiv($t,10);
- }
- if($digit>1)
- {
- $rev="Sigle digit needed[1-9]!";
- }
- else
- {
- $t=$_POST['no'];
- if($t>0)
- {
- $rev=$_POST['no']."! => ";
- $ans=1;
- $i=0;
- for($i=1;$i<=$_POST['no'];$i++)
- {
- $ans=$ans*$i;
- }
- $rev=$rev.$ans;
- }
- else
- {
- $rev="Nagative or zero value will not Accepted";
- }
- }
- }
- else
- {
- $rev="SElect the opration";
- }
- }
- ?>
- <html>
- <head>
- <title>task - 1</title>
- </head>
- <style>
- body
- {
- background-image:url('backgrounds/66.jpg');
- background-size:100%;
- backdrop-filter:blur(4px);
- margin:0;padding:0;height:100%;
- }
- .l
- {
- background-color:black;
- color:White;
- font-size:30px;
- }
- .l1
- {
- //background-color:black;
- color:White;
- font-size:40px;
- height:60px;
- width:100%;
- background-color:transparent;
- border:0;
- text-align:center;
- }
- h1
- {
- background-color:black;
- color:White;
- font-size:50px;
- text-align:center;
- }
- td
- {
- width:50%;
- }
- </style>
- <body>
- <form name="f1" method="post">
- <h1>TASK - 1</h1>
- <table border="0" cellspacing="25"align="center" width="70%">
- <tr>
- <td align="right"><label class="l" > Enter the Number</label>
- </td>
- <td><input type="textbox" name="no" style="width:100%" class="l"placeholder="Enter here!!">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top" align="right"><label class="l">Option</label></td>
- <td>
- <input type="radio" name="op" value="Reverse"class="l"><label class="l">Reverse</label><br><br>
- <input type="radio" name="op" value="Palindrom"class="l"><label class="l">Palindrom</label><br><br>
- <input type="radio" name="op" value="Armstrong"class="l"><label class="l">Armstrong</label><br><br>
- <input type="radio" name="op" value="Fibonaci"class="l"><label class="l">Fibonaci(single digit only)</label><br><br>
- <input type="radio" name="op" value="Factorial"class="l"><label class="l">factorial(single digit only)</label><br><br>
- </td>
- </tr>
- <tr>
- <td colspan="2" align="center">
- <input type="submit" name="sub" value="Ans" class="l" style="width:40%;height:50px">
- </td>
- </tr>
- <tr>
- <td colspan="2" align="center">
- <input type="text" name="report" class="l1"readonly value="<?php echo $rev;?>">
- </td>
- </tr>
- </table>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement