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

I need help in phpbb modifications for course type forum, PHPBB modificatio...

PHPBB modifications (course type forum) I desire to make a different view/organization of the viewForum.php for my phpBB site. To support this change certain changes desires

We looking for programmer to create game, We looking for programmer to crea...

We looking for programmer to create game Responsibilities- 1) Customize tabs in FB 2) Create a game like wheel of fortune. Qualifications: 1) Very good in programmin

Social network connecting college students, Text-Book This is a new conc...

Text-Book This is a new concept that is needed to be brought to life. More will be discussed with the Developer I am working with. In a nut shell it is a social network connecti

Modify auth on code igniter for cakephp, Modify auth on code igniter for ca...

Modify auth on code igniter for cakephp auth, SSO lite Project Description: I start to develop apps with cakephp, but now i wish to add forum made with code igniter. i nee

Date, Returns the current date comprising date, month, & year. Note that th...

Returns the current date comprising date, month, & year. Note that the getMonth method returns 0 in December, 1 in January etc. thus add 1 to the getMonth method to display the cor

Form target attribute, Corresponds to the FORM TARGET attribute. • Tex...

Corresponds to the FORM TARGET attribute. • Text - It is an object representing a text field. • Text area - It is an object representing a text area field. Some of the F

Professional expert web engineer wanted for start-up, Professional expert w...

Professional expert web engineer wanted for exciting start-up We are changing the method the world publishes, promotes and consumes video. We are in search of a talented free

We need help to create ecommerce and software app, We need help to create E...

We need help to create Ecommerce and Software App Development For Yahoo / Shopify I am in search of a developer or company to build an App that can work with Yahoo Stores and Sh

Want help in magneto multi-vendor store, Magneto multi-vendor store We a...

Magneto multi-vendor store We are looking for a Magneto multi-vendor store. We need a developer that has already developed the same type of site therefore that we can edit & twe

Need help to set ogone payment module for magento shop, Set Ogone payment m...

Set Ogone payment module for magento shop Seeking a magento developer who can set the Payment settings for a Magento store client of us. And likewise fix some other issues fo

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