473,405 Members | 2,262 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,405 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 1163
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.