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

Telnet, Telnet is both a TCP/IP application & protocol for linking a local ...

Telnet is both a TCP/IP application & protocol for linking a local computer to a remote computer. It is the Internet remote login service. Telnet protocol defines exactly how a rem

I need help in buddypress project, I need help in Buddypress project I h...

I need help in Buddypress project I have a Buddypress site that I want some help with please. 1. The job needs that you know how to build a new Buddypress group component. Th

Need help in wordpress site with e-commerce integration, WordPress Site wit...

WordPress Site with E-Commerce Integration We want development of a site in Word Press. We will offer the designs and the content. We will want you to set up the site and conver

Newbi, how use the simple aplication for web with php fron iner and mysql t...

how use the simple aplication for web with php fron iner and mysql the databse

Needed a magento virtual assistant, MAGENTO VIRTUAL ASSISTANT Our websit...

MAGENTO VIRTUAL ASSISTANT Our website is constructed on MAGENTO Platform. We want an individual with strong knowledge of MAGENTO Back end office to look after our website, up

Want expert assistance in wordpress plugin development, Wordpress Plugin De...

Wordpress Plugin Development Our company is needing somebody with awesome skills like yours to build a custom WP Plugin are you available for the project? Desired Skills are

Graphical browsers, Graphical browsers: In order to enjoy the multimed...

Graphical browsers: In order to enjoy the multimedia aspect of the Web, you have to use a graphical browser like Netscape Navigator or NCSA Mosaic. Graphical browsers can illu

We need help to fix drupal 5.0 site, We need help to Fix Drupal 5.0 site. A...

We need help to Fix Drupal 5.0 site. Authorize.net not working We have a Drupal 5.0 site that abruptly isn't connecting with Authorize.net. Fundamentally, we are having some

Api replication required, Project Description: Want an API expert to aid...

Project Description: Want an API expert to aid in application development in regards to API extraction, and injection into other sites, as the main site is updated. Do not bid i

Web site on cake php to be redesigned, Web Site on Cake PHP to be redesigne...

Web Site on Cake PHP to be redesigned and Things to be added Project Description: We have a web site that has some finishing off and also fixing some bugs. We will consider I

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