0% found this document useful (0 votes)
32 views16 pages

CSS Practical 01-05

Uploaded by

vinitsahare963
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views16 pages

CSS Practical 01-05

Uploaded by

vinitsahare963
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Practical 1

 Aim : Write simple Javascript with HTML for arithematic expression


evaluation and message printing.

 Thoery:
JavaScript is a scripting or programming language that allows you to implement
complex features on web pages. It is well-known for the development of web
pages, and many non-browser environments also use it.

JavaScript is one of the 3 languages all web developers must learn:

 HTML is the markup language that we use to structure and give


meaning to our web content, for example defining paragraphs,
headings, and data tables, or embedding images and videos in the page.

 CSS is a language of style rules that we use to apply styling to our


HTML content, for example setting background colours and fonts, and
laying out our content in multiple columns.

 JavaScript is a scripting language that enables you to create


dynamically updating content, control multimedia, animate images,
and pretty much everything else.

General Syntax for writing javascript program :

<html>

<head>

<title> Name of Program </title>

<body>

<script>

// Executable code

</script>

</body>

</head>

</html>
 Program Code :

<html>
<head>
<title> Arithematic Operation</title>
<script type=”text/javascript”>
var a,b;
{
a=(parseInt(prompt("Enter a number")));
b=(parseInt(prompt("Enter second number")));
}

document.write("Addition is :- "+(a+b));
document.write("<br> Substraction is :- "+(a-b));
document.write("<br> Multiplication is :- "+(a*b));
document.write("<br> Division is :- "+(a/b));
document.write("<br> Modulus Division is :- "+(a%b));
document.write("<br> Increement of First number is :- "+(++a));
document.write("<br> Increement of Second number is :- "+(++b));
document.write("<br> Decreement of First number is :- "+(--a));
document.write("<br> Decreement of Secondd number is :- "+(--b));

</script>
</head>
</html>
 Output :

Marks Obtained Dated


Signature
of
Teacher
Process Product Total
Related(10) Related(15 ) (25)
Practical 2
Aim : Develop a Javascript to use decision making and looping statements.

Thoery:
Decision Making Statements :
 A programming language uses control statements to control the flow of execution
of the program based on certain conditions.
 JavaScript’s conditional statements are:

1) if
statement:
Syntax:
if (condition) {
//true block
}

2) if-else
statement:
Syntax:
if(condition){
//true block
} else {
//false block

}
3) if…else…if

Syntax:
if(condition
{
if(condition1from1){
//true block
} else {
//false block
}else{
//false block from condition 2
}}

Looping Statements :
Looping in programming languages facilitates the execution of a set of
instructions/functions repeatedly while some condition evaluates to true.
Following are the types of loops in JavaScript:
1) while loop

2) do-while loop
3) for loop

Program Code for Conditional Statement:

<html>
<head>
<script type="text/javascript">
var a=parseInt(prompt("Enter First Number : "));
var b=parseInt(prompt("Enter Second Number : "));
var c=parseInt(prompt("Enter Third Number : "));
if(a>b && a>c)
{
document.write(a+" Number is Greater ");
}
else if(b>a && b>c)
{
document.write(b+" Number is Greater ");
}
else if(c>a && c>b)
{
document.write(c+" Number is Greater ");
}
else
{
document.write("All Number are Equals");
}
</script>
</head>
</html>
Output:

Program Code for Looping Statement:

<html>
<head>
<script type="text/javascript">
var a=prompt("Enter a Number : ");
for(var i=1;i<=10;i++)
{
document.write("<br>"+a+" * "+i+" = "+(a*i));
}
</script>
</head>
</html>

Output:
Marks Obtained Dated
Signature
of Teacher
Process Product Total
Related(10) Related(15) (25)
Practical 3
Aim : Develop a Javascript to implement Array functionalities.

Thoery:
What is an Array?
An array is a special variable, which can hold more than one value at a time.
Creating an Array Using an array literal is the easiest way to create a JavaScript
Array.
There are two ways of declaring an array in Javascript
1) By array literal :
This is the easiest way to create a JavaScript Array.
Syntax: var array_name = [item1, item2,

…,itemn]; Example: var colors =

[“Red”,”Yellow”,”Orange”]

2) By using an Array constructor (using new keyword)


We can also create an array using Array constructor with
new keyword. This declaration has five parts:
1) var keyword
2) Array name
3) Assignment operator
4) new operator
5) Array ( ) constructor

Syntax: var array_name = new


Array();. Example: var names
=new Array();
Program Code:

<html>
<title>Practical 3</title>
<body>
<script>
var strArray=new Array("Vinit","Soham","Rakesh","Sanjay","Mayur")
var numArray=new Array(10,20,22.5,30,87,88);
document.write("<br> Original String Array elements are : "+strArray);
document.write("<br> Original Numeric Array elements are : "+numArray);

document.write("<br> Length String Array elements are : "+strArray.length);


document.write("<br> Length Numeric Array elements are :
"+numArray.length);

document.write("<br> Sorted Numeric Array elements are : "+numArray.sort());


document.write("<br> Sorted String Array elements are : "+strArray.sort());

numArray.push(55);
document.write("<br> New Numeric Array elements after push() : "+numArray);
strArray.push("Monish");
document.write("<br> New String Array elements after push() : "+strArray);

</script>
</body>
</html>
Output:

Marks Obtained Dated


Signature
of
Teacher
Process Product Total
Related(10) Related(15) (25)
Practical 4

Aim : Develop a Javascript to implement functions.

Thoery:
Function
JavaScript functions are used to perform operations. We can call JavaScript
function many times to reuse the code.

Advantage of JavaScript function


There are mainly two advantages of JavaScript functions.
1. Code reusability: We can call a function several times so it save coding.

2. Less coding: It makes our program compact. We don’t need to write many lines
of code each time to perform a common task.
JavaScript Function Syntax:
function function_Name([arg1, arg2, ...argN])
{
//code to be executed
}
JavaScript Functions can have 0 or more arguments.
Program Code :

<html>
<title>Practical 4</title>
<body>
<script>
var patient_name,patient_no,patient_mob_no,patient_add;
function accept(){
patient_name=prompt("Enter Patient Name: ");
patient_no=parseInt(prompt("Enter Patient Number : "));
patient_mob_no=prompt("Enter Patient Mobile Number: ");
patient_add=prompt("Enter Patient Address : ");
}

function show(){
document.write("<br> Patient Name is "+patient_name);
document.write("<br> Patient Number is "+patient_no);
document.write("<br> Patient Mobile Number is "+ patient_mob_no);
document.write("<br> Patient Address is "+patient_add);
}

accept();
show();

</script>
</body>
</html>
Output :

Marks Obtained Dated


Signature
of Teacher
Process Product Total
Related(10) Related(15) (25)
Practical 5

Aim : Develop a Javascript to implement Strings.

Thoery:
String:
A JavaScript string stores a series of characters like "Vinit Sahare". A string can be
any text inside double or single quotes:
let carName1 = "Volvo XC60";
let carName2 = 'Volvo XC60';

Advantage of Strings:
There are some advantages of JavaScript Strings:
 Regular Expressions: Strings can be easily manipulated and searched using regular
expressions, which provide powerful pattern matching capabilities for validating and
extracting information.
 Built-in Methods: JavaScript provides a rich set of built-in methods for string
manipulation, such as charAt(), substring(), split(), replace(),
toUpperCase(), toLowerCase(), and more. These methods simplify common
tasks.
 Concatenation: Strings can be easily concatenated using the ‘+’ operator or
template literals (backticks), allowing for dynamic string creation and formatting.

 Readability: Strings are easy to read and write, making code more understandable,
especially when used for messages, prompts, and user
interface elements.

JavaScript String Syntax:

<String_name> = 'Hello, World!'; //Using Single Quote

<String_name> = "Hello, World!"; //Using Double_Quote


Program Code :

<html>
<head><title> String Implementation</title>
<script type="text/javascript">

var str1="Client Side ";


var str2="Scripting Language";
var str3=[1,2,3,4,5,6,7,8,9,0];

document.write(" Concatenation Of String is : "+(str1.concat(str2)));


document.write("<br> Join Method Of String is : "+(str3 .join("/")));
document.write(" <br>Character At Method Of String is : "+str1.charAt(5));
document.write("<br> Substring Method Of String is : "+(str1.substring(8,4)));
document.write(" <br>Split Method Of String is : "+(str1.split('')));
document.write(" <br>Repalce Method Of String is : "+(str2.replace("Scripting","Java")));
document.write("<br> UpperCase At Method Of String is : "+(str2.toUpperCase()));
document.write("<br> LowerCase Method Of String is : "+(str1.toLowerCase()));
document.write(" <br>Index Of Method Of String is : "+(str2.indexOf('p')));

</script>
</head>
</html>
Output :

Marks Obtained Dated


Signature
of Teacher
Process Product Total
Related(10) Related(15) (25)

You might also like