[go: up one dir, main page]

0% found this document useful (0 votes)
47 views8 pages

Experiment No. 01 Title: - Develop Javascript To Use Decision Making and Looping Statements. D.O.P

The document summarizes an experiment on developing JavaScript programs using decision making and looping statements. It includes 4 programs - 1) to calculate student grade and percentage from marks, 2) to display the Fibonacci series, 3) to calculate factorial of a number, and 4) to display even numbers between 1 to 50. It also includes exercises to explain JavaScript features like conditional operators and data types, and terms like objects and methods.

Uploaded by

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

Experiment No. 01 Title: - Develop Javascript To Use Decision Making and Looping Statements. D.O.P

The document summarizes an experiment on developing JavaScript programs using decision making and looping statements. It includes 4 programs - 1) to calculate student grade and percentage from marks, 2) to display the Fibonacci series, 3) to calculate factorial of a number, and 4) to display even numbers between 1 to 50. It also includes exercises to explain JavaScript features like conditional operators and data types, and terms like objects and methods.

Uploaded by

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

VES POLYTECHNIC CLIENT-SIDE SCRIPTING 22519

EXPERIMENT NO. 01

Title: - Develop Javascript to use decision


making and looping statements.

D.O.P: -

D.O.S: -

MARKS: -

Marks Obtained Dated signature of


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

CO5I - A 2021-22
VES POLYTECHNIC CLIENT-SIDE SCRIPTING 22519

Experiment No: 01

 AIM: Develop a JavaScript to use decision making and


loopingstatement.

 Student Activity:

1 .Write a program to display grade, average, percentage obtained


by student
2. Fibonacci series number
3. Factorial Number.
4. Display Even Numbers between 1 to 50

 Exercise:

1. Explain any two features of Javascript?


2. What is conditional operators in Javascript?
3. Explain six types of values in Javascript.
4. Explain the terms:- Object,Method.

CO5I - A 2021-22
Student Activity:

1 .Write a program to display grade, average, percentage obtained by student

<!DOCTYPE html>

<html lang="en">

<body>

<script>

var Maths = 60;

var Science = 80;

var English = 63;

var History = 71;

var average = (Maths + Science + English + History) / 4;

document.write(

"The average for the entered subjects is " + Math.round(average) + "<br>"

);

document.write(

"The percentage for the entered subject is " + average + "%<br>"

);

if (average >= 85 && average < 100) document.write("GRADE: A");

else if (average >= 60 && average < 85) document.write("GRADE: B");

else if (average >= 35 && average < 60) document.write("GRADE: C");

else if (average < 35) document.write("GRADE: D");

else document.write("average error");

document.write("Grade: " + grade);

</script>

</body>

</html>

Output:
2. Fibonacci series number

<!DOCTYPE html>

<html>

<body>

<script>

var a = 0, b = 1, c, i;

var num = 10;

document.write("Fibonacci Series : ");

for(i=1;i<=num;i++)

document.write("<br>" + a);

c = a + b;

a = b;

b = c;

</script>

</body>

</html>

Output:
3. Factorial Number.

<!DOCTYPE html>

<html lang="en">

<body>

<script type = "text/javaScript">

var num = 12;

var f = 1;

for(i = 1;i <= num; i++)

f = f*i;

document.write("Factorial of " + num + "= " + f);

</script>

</body>

</html>

Output:
4. Display Even Numbers between 1 to 50

<!DOCTYPE html>

<html>

<body>

<script>

var n = 50;

for(i=0;i<=n;i++)

if(i%2 == 0)

document.write(i + " ");

</script>

</body>

</html>

Output:
Exercise:

1. Explain any two features of Javascript?

• Browser Support: For running the JavaScript in the browser there isn’t any need
to use some plug-in. Almost all the popular browsers support JavaScripting.
• Run time evaluation: Using the eval function the expression can be
evaluated at run time.

2. What is conditional operators in Javascript?

We use else if to identify a new condition to test, if the first condition is false; else if
to identify a block of code to be executed, if a specified condition is true; else to
identify a block of code to be executed, if the same condition is false;

We use ‘?’ as shorthand for an if...else statement. We use switch to


identify a lot of alternative blocks of code to be executed.

3. Explain six types of values in Javascript.

Boolean:

Boolean represents a logical entity and can havetwo values: true and
false.

Null:

The Null type has exactly one value: null. If we try to access the null value then a
runtime error will occur.

String:

JavaScript's String type is used to represent textual data.

Number:

Number represents integer and floating numbers (decimals and exponentials). For
example: var number1 = 3;
Objects:

Objects are variables too. But objects can contain many values. For example,

var person = {firstName: Pranav ", lastName:"Mhatre", age:18"};

Function:

A JavaScript function is a block of code designed to perform a


particular task.

A JavaScript function is executed when something invokes it


(calls it).

There can be predefined functions and user defined functions.

4. Explain the terms:- Object, Method.

Object:

In JavaScript an object is a standalone entity, with properties and type.


JavaScript objects are containers for named values called properties
or methods.
Objects is nothing but some entity.
Example: document, window, forms, fields, button, etc.
var person = {firstName:"Pranav ", lastName:"Mhatre", age:18"};

Method:

Method is a function or a process associated with each object.


For example: for the document object method is write. To this write method
we pass the string which we want to display on the browser window.

You might also like