Returning a value, PHP Web Programming

Assignment Help:

Another function of a function is to return a value. Imagine we have the following function:

<HTML>

<HEAD>

<TITLE>IGNOU </TITLE>

<SCRIPT Language = "JavaScript">

function calculate(a,b,c)

{

d = (a+b) * c;

return d;

}

</SCRIPT>

</HEAD>

<BODY>

<SCRIPT Language = "JavaScript">

var x = calculate(4,5,9);

var y = calculate((x/3),3,5);

alert('calculate(4,5,9) = ' +x + ' and ' + ' calculate((x/3),3,5) = ' + y);

</SCRIPT>

</BODY>

</HTML>

 

322_Returning a value.png

Figure:  Using a Function that Returns a Value

The function illustrated in Figure calculates a number from the numbers you pass to it. While this is done it returns the result of the calculation. The function passes the result back to the function which called it. While the function executes return statement, control goes back to the calling program without executing any more code in function, if there is any.

The calling of the function is done via the following two statements in the figure:

var x = calculate(4,5,9);

var y = calculate((x/3),3,5);

This means that you have declared variable x and are telling JavaScript to execute calculate ( ) along the arguments 4, 5 & 9 and to put the returned value (81) in x. After that you declare a variable y and execute calculate ( ) again. The first argument is x/3, which means 81/3 = 27, thus y becomes 150.Certainly you can also return strings or even Boolean values (true or false). While using JavaScript in forms, you can write a function which returns either false or true and therefore tells the browser whether to submit form or not.


Related Discussions:- Returning a value

Need experienced php developer, I need Experienced Php developer.with subse...

I need Experienced Php developer.with subsequent skills Cakephp, Wordpress, Codeigniter , Php,Mysql,Ajax. Skills required: CakePHP, MySQL, Codeigniter, PHP, Wordpress

I need a web developer develop a simple corporate responsive, I need a Web ...

I need a Web Developer Start-up company in Tel Aviv is looking for a talented Web Developer to develop a simple (no backend) corporate responsive website of 5 Pages Job descript

Codes for fashion website built on magento, Fashion Website fixes Codes ...

Fashion Website fixes Codes for fashion website built on magento needs to be cleaned up. Job description: Current issues include: a) Coding on magento is making site un

Definition lists, Another type of list is a definition list. Definition lis...

Another type of list is a definition list. Definition lists contain a heading & the text show below that. IGNOU <

Total makeover of existing bilingual website with seo, Total makeover of ex...

Total makeover of existing bilingual website with SEO • Offer an eye-catching, multilingual, easy to navigate and searchable website template offering several interactive featur

Dreamweaver, A Web site is a set of linked documents along shared attribute...

A Web site is a set of linked documents along shared attributes, such as associated topics, a similar design, or a shared reason. Macromedia Dreamweaver is site creation & manageme

Seeking an experienced web programmer/developer, Design as well as Develop ...

Design as well as Develop New Website Joomla 3.2 MUST Seeking an experienced web programmer/developer Type of work required - IT & Programming > Web Programming Seeking an

Need help to adding new tab on the website, Need help to Adding new tab on ...

Need help to Adding new tab on the website A new tab or link needs to be created on the website for customer reviews. The customers must be able to write about their experience

We need help in simple, We need help in Simple, Member-Based Fan Club Site ...

We need help in Simple, Member-Based Fan Club Site I play in an alternative-rock band as well as I am looking for someone to build a member-based website for our fan club. We do

Basics of hypertext markup language, In the form of hypermedia documents, W...

In the form of hypermedia documents, Web pages or materials accessed by the Internet can be located anywhere in the world. Regardless of where they originated, most of the Web d

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd