0% found this document useful (0 votes)
11 views2 pages

JavaScript Functions: Concepts & Examples

The document discusses JavaScript functions and provides examples. It covers topics like function definition syntax, parameters, return values, and using functions to modularize programs. Examples are given to find the cube of a number and sum of the first 10 numbers using functions.

Uploaded by

kms195kds2007
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)
11 views2 pages

JavaScript Functions: Concepts & Examples

The document discusses JavaScript functions and provides examples. It covers topics like function definition syntax, parameters, return values, and using functions to modularize programs. Examples are given to find the cube of a number and sum of the first 10 numbers using functions.

Uploaded by

kms195kds2007
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

11 Computer Applications

Chapter 16 / Java Script Functions

Part-I
Choose the correct answer:
1) The parameters work as
A) Local variable B) Global Variable C) File variable D) block variable
2) Predefined functions are also called as
A)Library functions B) storage functions C) instructions D) commands
3) Larger programs are divided into smaller called
A) modules B) block C) sets D) Group
4) Which of the following is used to enhance reusability and program clarity.
A) functions B) modules C) sets D) instructions

5) Which of the following allow the programmer to modularize a program


A) Library functions B) user defined functions
C) Normal functions D) Ordinary functions

Part – II
Very Short Answers
1) What is a function in JavaScript?
 Function is a named block of codes
 It can be called any number of times

2) What is the use of function?


 Code reusability
 Easy to debug
 Easy readability

3) Write a note on Library functions.


 Library functions are predefined functions.
 They are built-in

4) Write a note on user defined functions.


 Leads to modular programming
 defined for users need

5) Write the syntax of functions.


function function-name(parameters )
{ declaration of variables;
Executable statements;
}

11CA / 16 Java Script Functions / Page 1 of 2


Part-III
Short Answers
1) Write a program in JavaScript to find the cube of a number using function

<Html>
<Head>
<Title>Cube of a Number </Title>
</Head>
<Body>
<script language="javascript" type="text/javascript">
var n = prompt("Enter a number");
[Link]("The CUBE of the number is "+numcube(n));
function numcube(x)
{
var a=x*x*x;
return a;
}
</script> </Body> </Html>

2) Write a program in JavaScript to find the sum of 10 numbers using function.

<Html>
<Head>
<Title>SUM OF 10 NUM </Title>
</Head>
<Body>
<script language="javascript" type="text/javascript">
[Link]("The SUM of first 10 numbers is "+sumnum());
function sumnum()
{
var a;
var tot=0;
for(a=1;a<=10;a++)
{tot=tot+a;}
return(tot);
}
</script> </Body> </Html>

11CA / 16 Java Script Functions / Page 2 of 2

You might also like