Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /var/www/cgi-bin/2kl15cs019/tw
- <!DOCTYPE html>
- <html>
- <head>
- <title>Simple calculator</title>
- </head>
- <body>
- <script type="text/javascript">
- var num1 = parseInt(prompt("enter first number"));
- var num2 = parseInt(prompt("enter Second number"));
- var op =prompt("enter the operator");
- switch(op)
- {
- case "+":document.write("the addition of 2 Numbers is:", num1+num2);
- break;
- case "-":document.write("the sub of 2 Numbers is:", num1-num2);
- break;
- case "*":document.write("the mul of 2 Numbers is:", num1*num2);
- break;
- case "/":if (num2==0) {
- document.write("unable to do operation");
- }
- else
- {
- document.write("the div of 2 Numbers is:", num1/num2);
- }
- break
- }
- </script>
- </body>
- </html>
- 2)
- <!DOCTYPE html>
- <html>
- <head>
- <title>Cubes And Squares</title>
- </head>
- <body>
- <table align="Center" border="1">
- <tr><th>Number</th><th>Squares</th><th>Cubes</th></tr>
- <script type="text/javascript">
- for(var n=0;n<10;n++){
- document.write("<tr><td>"+n+"</td><td>"+n*n+"</td><td>"+n*n*n+"</td></tr>");
- }
- </script>
- </table>
- </body>
- </html>
- 3)
- <html>
- <body>
- <p id="demo"></p>
- <script>
- var var1 = setInterval(inTimer, 1000);
- var size = 5;
- var ids = document.getElementById("demo");
- function inTimer() {
- ids.innerHTML = 'TEXT GROWING';
- ids.setAttribute('style', "font-size: " + size + "px; color: red");
- size += 5;
- if(size >= 50 ){
- clearInterval(var1);
- var2 = setInterval(deTimer,1000);
- }
- }
- function deTimer() {
- size -= 5;
- ids.innerHTML = 'TEXT SHRINKING';
- ids.setAttribute('style', "font-size: " + size + "px; color: blue");
- if(size == 5 ){
- clearInterval(var2);
- }
- }
- </script>
- </body>
- </html>
- 4)
- <html>
- <body>
- <script type="text/javascript">
- var str = prompt("Enter the Input","");
- if(isNaN(str))
- {
- str = str.toUpperCase();
- for(var i = 0; i < str.length; i++) {
- var chr = str.charAt(i);
- if(chr == 'A' || chr == 'E' || chr == 'I' || chr == 'O' || chr == 'U')break;
- }
- if( i < str.length )
- alert("The position of the left most vowel is "+(i+1));
- else
- alert("No vowel found in the entered string");
- }
- else
- {
- var num,rev=0,remainder;
- num = parseInt(str);
- while(num!=0) {
- remainder = num%10;
- num = parseInt(num/10);
- rev = rev * 10 + remainder;
- }
- alert("Reverse of "+str+" is "+rev);
- }
- </script>
- </body>
- </html>
- 5)
- <?xml-stylesheet type="text/css" href="6.css" ?>
- <!DOCTYPE HTML>
- <html>
- <head>
- <h1> STUDENTS DESCRIPTION </h1>
- </head>
- <students>
- <student>
- <USN>USN : 1CG15CS001</USN>
- <name>NAME : SANTHOS</name>
- <college>COLLEGE : CIT</college>
- <branch>BRANCH : Computer Science and Engineering</branch>
- <year>YEAR : 2015</year>
- <e-mail>E-Mail : santosh@gmail.com</e-mail>
- </student>
- <student>
- <USN>USN : 1CG15IS002</USN>
- <name>NAME : MANORANJAN</name>
- <college>COLLEGE : CITIT</college>
- <branch>BRANCH : Information Science and Engineering</branch>
- <year>YEAR : 2015</year>
- <e-mail>E-Mail : manoranjan@gmail.com</e-mail>
- </student>
- <student>
- <USN>USN : 1CG15EC101</USN>
- <name>NAME : CHETHAN</name>
- <college>COLLEGE : CITIT</college>
- <branch>BRANCH : Electronics and Communication Engineering
- </branch>
- <year>YEAR : 2015</year>
- <e-mail>E-Mail : chethan@gmail.com</e-mail>
- </student>
- </students>
- </html>
- 6)
- <?php
- print "<h3> REFRESH PAGE </h3>";
- $name="counter.txt";
- $file = fopen($name,"r");
- $hits= fscanf($file,"%d");
- fclose($file);
- $hits[0]++;
- $file = fopen($name,"w");
- fprintf($file,"%d",$hits[0]);
- fclose($file);
- print "Total number of views: ".$hits[0];
- ?>
- 7)<html>
- <head>
- <meta http-equiv="refresh" content="1"/>
- <style>
- p {
- color:white;
- font-size:90px;
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- }
- body{background-color:red;}
- </style>
- <p> <?php echo date(" h: m : s A");?> </p>
- </head>
- </html>
- 8a)
- <html>
- <head>
- <style>
- table, td, th
- {
- border: 1px solid black;
- width: 35%;
- text-align: center;
- background-color: DarkGray;
- }
- table { margin: auto; }
- input,p { text-align:right; }
- </style>
- </head>
- <body>
- <form method="post">
- <table>
- <caption><h2> SIMPLE CALCULATOR </h2></caption>>
- <tr><td>First Number:</td><td><input type="text" name="num1" /></td>
- <td rowspan="2"><input type="submit" name="submit"
- value="calculate"></td></tr>
- <tr><td>Second Number:</td><td><input type="text"
- name="num2"/></td></tr>
- </form>
- <?php
- if(isset($_POST['submit']))
- {
- $num1 = $_POST['num1'];
- $num2 = $_POST['num2'];
- if(is_numeric($num1) andis_numeric($num1) )
- {
- echo "<tr><td> Addition :</td><td><p>".($num1+$num2)."</p></td>";
- echo "<tr><td> Subtraction :</td><td><p> ".($num1-$num2)."</p></td>";
- echo "<tr><td> Multiplication :</td><td><p>".($num1*$num2)."</p></td>";
- echo "<tr><td>Division :</td><td><p> ".($num1/$num2)."</p></td>";
- echo "</table>";
- }
- else
- {
- echo"<script type='text/javascript' > alert(' ENTER VALID NUMBER');</script>";
- }
- }
- ?>
- </body>
- </html>
- 8b)<?php
- $a = array(array(1,2,3),array(4,5,6),array(7,8,9));
- $b = array(array(7,8,9),array(4,5,6),array(1,2,3));
- $m=count($a);
- $n=count($a[2]);
- $p=count($b);
- $q=count($b[2]);
- echo "the first matrix :"."<br/>";
- for ($row = 0; $row < $m; $row++) {
- for ($col = 0; $col < $n; $col++)
- echo " ".$a[$row][$col];
- echo "<br/>";
- }
- echo "the second matrix :"."<br/>";
- for ($row = 0; $row < $p; $row++) {
- for ($col = 0; $col < $q; $col++)
- echo " ".$b[$row][$col];
- echo "<br/>";
- }
- echo "the transpose for the first matrix is:"."<br/>";
- for ($row = 0; $row < $m; $row++) {
- for ($col = 0; $col < $n; $col++)
- echo " ".$a[$col][$row];
- echo "<br/>";
- }
- if(($m===$p) and ($n===$q)) {
- echo "the addition of matrices is:"."<br/>";
- for ($row = 0; $row < 3; $row++) {
- for ($col = 0; $col < 3; $col++)
- echo " ".$a[$row][$col]+$b[$row][$col]." ";
- echo "<br/>";
- }
- }
- if($n===$p){
- echo " The multiplication of matrices: <br/>";
- $result=array();
- for ($i=0; $i < $m; $i++) {
- for($j=0; $j < $q; $j++){
- $result[$i][$j] = 0;
- for($k=0; $k < $n; $k++)
- $result[$i][$j] += $a[$i][$k] * $b[$k][$j];
- }
- }
- for ($row = 0; $row < $m; $row++) {
- for ($col = 0; $col < $q; $col++)
- echo " ".$result[$row][$col];
- echo "<br/>";
- }
- }
- ?>
- 9)<?php
- $states = "Mississippi Alabama Texas Massachusetts Kansas";
- $statesArray = [];
- $states1 = explode(' ',$states);
- foreach($states1 as $state) {
- if(preg_match( '/xas$/', ($state)))
- $statesArray[0] = ($state);
- }
- foreach($states1 as $state) {
- if(preg_match( '/Kansas$/', ($state)))
- $statesArray[1] = ($state);
- }
- foreach($states1 as $state) {
- if(preg_match( '/Massachusetts$/', ($state)))
- $statesArray[2] = ($state);
- }
- foreach($states1 as $state) {
- if(preg_match( '/Alabama$/', ($state)))
- $statesArray[3] = ($state);
- }
- foreach ( $statesArray as $element => $value ){
- print( $value." is the element ". $element."<br/>");
- }
- ?>
- 10)mysql -u root
- mysql>create database 2kl15cs019
- mysql>use 2kl15cs019
- create table student(usn varchar(10),name varchar(20),address varchar(20));
- insert into student values('19','daya','bijapur')
- <html>
- <body>
- <style>
- table, td, th
- {
- border: 1px solid black;
- width: 33%;
- text-align: center;
- border-collapse:collapse;
- background-color:lightblue;
- }
- table { margin: auto; }
- </style>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "weblab";
- $a=[];
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection and return an error description from the last connection error, if any
- if ($conn->connect_error)
- die("Connection failed: " . $conn->connect_error);
- $sql = "SELECT * FROM student";
- // performs a query against the database
- $result = $conn->query($sql);
- echo "<br>";
- echo "<center> BEFORE SORTING </center>";
- echo "<table border='2'>";
- echo "<tr>";
- echo "<th>USN</th><th>NAME</th><th>Address</th></tr>";
- if ($result->num_rows> 0)
- {
- // output data of each row and fetches a result row as an
- while($row = $result->fetch_assoc()){
- echo "<tr>";
- echo "<td>". $row["usn"]."</td>";
- echo "<td>". $row["name"]."</td>";
- echo "<td>". $row["address"]."</td>";
- echo "</tr>";
- array_push($a,$row["usn"]);
- }
- }
- else
- echo "Table is Empty";
- echo "</table>";
- $n=count($a);
- $b=$a;
- for ( $i = 0 ; $i< ($n - 1) ; $i++ )
- {
- $pos= $i;
- for ( $j = $i + 1 ; $j < $n ; $j++ ) {
- if ( $a[$pos] > $a[$j] )
- $pos= $j;
- }
- if ( $pos!= $i ) {
- $temp=$a[$i];
- $a[$i] = $a[$pos];
- $a[$pos] = $temp;
- }
- }
- $c=[];
- $d=[];
- $result = $conn->query($sql);
- if ($result->num_rows> 0)// output data of each row
- {
- while($row = $result->fetch_assoc()) {
- for($i=0;$i<$n;$i++) {
- if($row["usn"]== $a[$i]) {
- $c[$i]=$row["name"];
- $d[$i]=$row["address"];
- }
- }
- }
- }
- echo "<br>";
- echo "<center> AFTER SORTING <center>";
- echo "<table border='2'>";
- echo "<tr>";
- echo "<th>USN</th><th>NAME</th><th>Address</th></tr>";
- for($i=0;$i<$n;$i++) {
- echo "<tr>";
- echo "<td>". $a[$i]."</td>";
- echo "<td>". $c[$i]."</td>";
- echo "<td>". $d[$i]."</td></tr>";
- }
- echo "</table>";
- $conn->close();
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment