| Sr.No | Assignment name |
|---|---|
| Set-A | |
| 1 |
Write a php script to perform following operations on Indexed Array. a) Unions of two arrays. b) Traverse the array elements in random order. Plz Click on Question to see Answer<?php function array_union($x, $y) { $aunion= array_merge ( array_intersect($x, $y), array_diff($x, $y), array_diff($y, $x) ); return $aunion; } $a = array(4, 5, 3, 4); $b = array(1, 2, 3, 4, 5); echo"Unions of two arrays is : <br>"; print_r(array_union($a, $b)); echo"<br>"; echo"<br>Traverse the array elements in random order <br>"; shuffle($b); print_r($b); ?> |
| 2 |
Write a menu driven program in PHP to perform the following operations on an associative array: a) Display the elements of an array along with the keys. b) Display the size of an array c) Delete an element from an array from the given index. d) Reverse the order of each element's key-value pair. e)Traverse the elements in an array in random order. Plz Click on Question to see Answer<html> <form action='aq2.php' method='post'> 1<input type='radio' name='a' value='1'> Display the elements of an array along with the keys.<br> 2<input type='radio' name='a' value='2'> Display the size of an array.<br> 3<input type='radio' name='a' value='3'> Delete an element from an array from the given index.<br> 4<input type='radio' name='a' value='4'> Reverse the order of each element's key-value pair.<br> 5<input type='radio' name='a' value='5'> Traverse the elements in an array in random order.<br> <input type='submit' value='ok'> </form> </body> </html> <?php $array=array('zero'=>0,'one'=>1,'two'=>2, 'three'=>3,'four'=>4,'five'=>5); $ch=$_POST['a']; switch($ch) { case 1:foreach($array as $key=>$value) { echo"key:$key val:$value."; } break; case 2:echo sizeof($array); break; case 3 : $len=sizeof($array); array_splice($array,$len); print_r( $array); break; case 4 : print_r(array_flip($array)); break; case 5 : shuffle($array); print_r($array); break; } ?> |
| 3 |
Write a php script to display the grade of the student according to percentege.Use the following conditions. i. percentage<40=>Grade="Fail" ii.percentage>=40 and percentage<=50=>Grade="Pass class" iii.percentage>=50 and percentage<=60=>Grade="Higher Class" iv. percentage>60 and percentage<=70=>Grade="First class" v. Percentage>=70=>Grade="First class with Distinction". Plz Click on Question to see Answer<html> <body> <form method="post" action="aq3.php"> Enter Percentage: <input type="text" name="t1"><br> <input type="submit" value="ok"> </form> </body> </html> <?php $p=$_POST["t1"]; if($p<40) echo("Grade : fail"); else if ($p>=40 && $p<=50) echo("Grade : pass"); else if ($p>=50 && $p<=60) echo("Grade : Higher second Class"); else if ($p>=60 && $p<=70) echo("Grade : First class"); else if ($p>=70) echo("Grade : First calss with Distinction"); ?> |
| Set-B | |
| 1 |
Write a php Script to display prime numbers between 1 to 50. Plz Click on Question to see Answer<?php echo"prime numbers form 1 to 50 are :"; echo"<br>"; for($number=1;$number<=100;$number++) { $count=0; for($i=02;$i<=$number/2;$i++) { if($number%$i==0) { $count++; break; } } if($count==0 && $number!=1) { echo $number." ,"; } } ?> |
| 2 |
Write a PHP script to display Perfect numbers between 1 to 100. Plz Click on Question to see Answer<?php $number=1; $sum=0; $p; echo"perfect numbers between 1 to 100 are :<br>"; for($i=1;$i<=100;$i++) { $p=1; while($p<=($i/2)) { if($i % $p==0) $sum=$sum+$p; $p++; } if($sum==$i) echo $i." "; $sum=0; } ?> |
| 3 |
Write a PHP script to display reverse of a number.eg.607=>706 Plz Click on Question to see Answer<?php $num = 607; $revnum = 0; while ($num != 0) { $revnum = $revnum * 10 + $num % 10; //below cast is essential to round remainder towards zero $num = (int)($num / 10); } echo "Reverse number: $revnum"; ?> |
| 4 |
Write a PHP script to display Armstrong number between 1 to 500. Plz Click on Question to see Answer<?php $count=1; echo"Armstrong numbers between 1 to 500 are :<br>"; while($count<=500) { $num=$count; $sum=0; while($num) { $rem=$num%10; $sum=$sum+($rem*$rem*$rem); $num=$num/10; } if($count==$sum) { echo $count."<br>"; } $count++; } ?> |
| Set-C | |
| 1 |
Write a PHP script to display to display the number in words.(Use Switch Case)e.g 345-three four five Plz Click on Question to see Answer<html> <body> <form method="post" action="cq1.php"> Enter The Number: < input type="text" name="t1"><br> <input type="submit" value="submit"> </form> </body> </html> <?php $n=$_POST["t1"]; switch($n) { case "0":echo "ZERO"; break; case "1":echo "ONE"; break; case "2":echo "TWO"; break; case "3":echo "THREE"; break; case "4":echo "FOUR"; break; case "5":echo "FIVE"; break; case "6":echo "SIX"; break; case "7":echo "SEVEN"; break; case "8":echo "EIGHT"; break; case "9":echo "NINE"; break; } ?> |
| 2 |
Write a PHP script to change the background color of the browser using a switch statement according to the day of the week. Plz Click on Question to see Answer<html> <head> <form method=post action="cq2.php"> <input type=radio name=r1 value=1>MONDAY<br> <input type=radio name=r1 value=2>TUESDAY<br> <input type=radio name=r1 value=3>WEDNESDAY<br> <input type=radio name=r1 value=4>THURDAY<br> <input type=radio name=r1 value=5>FRIDAY<br> <input type=radio name=r1 value=6>SATURDAY<br> <input type=radio name=r1 value=7>SUNDAY<br> <input type=submit value=change> </form> </head> </html> <?php $opt=$_POST['r1']; switch($opt) { case 1: echo"<body bgcolor=red>"; echo "<h3>Page colour changed Red</h3>"; break; case 2: echo"<body bgcolor=blue>"; echo "<h3>Page colour changed Blue</h3>"; break; case 3: echo"<body bgcolor=cyan>"; echo "<h3>Page colour changed Cyan</h3>"; break; case 4: echo"<body bgcolor=yellow>"; echo "<h3>Page colour changed Yellow</h3>"; break; case 5: echo"<body bgcolor=brown>"; echo "<h3>Page colour changed Brown</h3>"; break; case 6: echo"<body bgcolor=green>"; echo "<h3>Page colour changed green</h3>"; break; case 7: echo"<body bgcolor=pink>"; echo "<h3>Page colour changed pink</h3>"; break; } ?> |
- Home
- SYLLABUS
- _FYBBA(CA)
- __DBMS
- __WEB TECHNOLOGY
- _SYBBA(CA)
- __PHP
- __ADVANCE PHP
- _TYBBA(CA)
- __CORE JAVA
- __ADVANCE JAVA
- NOTES
- _Database System
- __CHAPTER1
- __CHAPTER 2
- _Web Technology
- __Chapter-1
- __Chapter-2
- __Chapter-3
- _Advance PHP
- __Chapter-1
- __Chapter-2
- __Chapter-3
- Research
- About us
- Assignment
- certificate
- Solved Programs
- Problem
- _Lab Book
- _Practical Slips
- _Assignment Submit
- _Project Guideline
- __SYBBACA SEM-IV
- __TYBBACA SEM-V
- __TYBBACA SEM-VI
- _C language
- __Simple Program
- __Simple Program
0 Comments