473,238 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,238 software developers and data experts.

organizing app and data

I am reading a book right now, but I don't that this
double grade(double midterm, double final, double homework)
{
return 0.2*midterm+0.4*final+0.4+homework;
}
what does that means?????
plz help
And how does it work, declaring a variable inside and another.
How to this help organizing app.
And how does this return work.
Plz help
Sep 11 '07 #1
3 1159
rhitam30111985
112 100+
above piece of text is known as a function... and no variable is being declared in it.. it is called a parameter... u can pass values to this function
as shown below:

Expand|Select|Wrap|Line Numbers
  1. double grade(double midterm, double final, double homework)
  2. {
  3. return 0.2*midterm+0.4*final+0.4+homework;
  4. }
  5.  
  6. void main()
  7. {
  8.    double mid=56.7,fin=43.2,home=33.8 ;
  9.    double result=grade(mid,fin,home) ; // the values of mid ,fin,home wud    be copied to midterm,final ,homework
  10.     cout<<result;
  11. //result gets the value that is "returned " or obtained from the function //"grade"  for this purpse the keyword retirn is used..
  12.  
Sep 11 '07 #2
u can pass values to this function, what goods does that offer.
And for the return value, returning to that what good is that.
Err, still don't quite get the example.
Sorry about that, and the late reply.
I am deeply sorry.
Sep 12 '07 #3
sicarie
4,677 Expert Mod 4TB
u can pass values to this function, what goods does that offer.
And for the return value, returning to that what good is that.
Err, still don't quite get the example.
Sorry about that, and the late reply.
I am deeply sorry.
Have you had to do a program that converts Celsius to Fahrenheit and vice-versa yet? Maybe something that calculates a standard deviation?

These small but frequently used modules, things that will take the same input and give a useful output, are frequently made as functions. This provides another layer of abstraction, and allows you to further modularize your code. It keeps you from writing the same code more than once.

In your example, this is useful because the grade will need to be calculated for each student. So instead of doing it by hand and possibly making mistakes, you can just put the grades into a file, and have it automatically calculated.

And how does it work, declaring a variable inside and another.
How to this help organizing app.
And how does this return work.
Plz help
When you declare a variable inside a function, you need to look at the rules of scope, which usually refer to the braces it is inside { }. When it's declared in a loop, after the loop exits, the variable (and it's value) are "forgotten" because that loop has ended. It's the same with a function, when it's done, the location is marked as free memory to be overwritten, which is why a return statement is necessary. You return the value you want to "remember" from the function.
Sep 12 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: ToMeK | last post by:
hi! i'm trying to builid web catalog and i'm having problems with organizing my tables. here's what i want: i have main categories, sub_categories and articles like this: CATEGORY_1 SUB_CAT_1...
0
by: GBartgo | last post by:
Hi everybody, I don't know how to initialize the weight vector of each node in the tree. The input is a set of N data in M dimensions. I have to realize a software based on the article "S-TREE:...
3
by: Jamie | last post by:
Hi, Thanks for the excellent answer to my last question! One more: Does anyone have a method they follow for organizing stylesheets themselves? They seem like they can get bloated and hard to...
1
by: Andrea | last post by:
Hi All, I am looking for SOM running under WIN32 and Microsoft Visual Studio 6.0. Can anybody help me? Andrea p.s. I apologize for cross-posting, but I have to solve this problem quickly :|
10
by: Rada Chirkova | last post by:
Hi, at NC State University, my students and I are working on a project called "self-organizing databases," please see description below. I would like to use an open-source database system for...
0
by: netsurfer802 | last post by:
I have a question regarding working with seperate files and organizing these files. The company I'm working for is a small comuter company that calls people that have went to computer trade...
1
by: Ushach | last post by:
hi, I want to know about Self Organizing maps.T ounderstand the concept ,I need a small example which explains how clustering is done through self organizing maps?If any body implemented it plz...
6
by: xkenneth | last post by:
All, Just a quick question. I want to be able to have a data structure that organizes data (timestamps I'm working with) sequentially, so that i can easily retrieve the first x amount of...
2
by: jehugaleahsa | last post by:
Hello: I have a bunch of related items that are either parents, children or not directly related to each other. In my case, I have a bunch of database tables joined with foreign keys. Another...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.