Friday, December 19, 2008

TIPS FOR USER-DEFINED FUNCTION in c++

DEFINITION - A UDF IS A NAMED GROUP OF PROGRAM STATEMENTS. THIS UNIT CAN BE INVOKED FROM OTHER PARTS OF THE PROGRAM AND MAY OR MAY NOT RETURN A VALUE.
THEY ARE BROADLY CATEGORISED IN TWO CATEGORIES -
1. Standard Library functions ( Bulid-in functions) - Are provided by the language itself.
2. User Defined function - Are made by the user .
Every UDF has three statements-
1. Function declaration or function prototype.
eg - void trunc( float, int &, int &);
2. Function definition block or function body.
eg - void trunc( float a, int &b, int &c)
{-------- }
3. Function call.
eg- trunc(a,b,c)
NOTE_ ORDER AND NUMBER OF PARAMETERS SHOULD MATCH THE FUNCTION HEADER.
Each of these staements consists of following parts-
1. return type of the function - is a valid data type . In case no value is returned by the function the return type will be void .
2. Function name - Any name adhering to the valid identifier naming rules should be used.
NOTE - DO NOT USE BUILD_IN FUNCTIONS NAMES FOR USER-DEFINED FUNCTIONS.
3. Parameter list - consist of varaibles with their data-type seperated by comma. If no parameters exists then this list is void.
eg- 1. void prn(void) or void prn() - No return-type & no parameters.
2. void prn(int, float, char) - - No return -type & three paameters.
3. float prn ( ) - Return type float and no parameters.
4. float prn( float, int) - return type float and two parameters.
NOTE- Depending on the problem the function will be defined using these four possible ways.
Possible function styles -
1. Function body appears before function call(usually in main()) , then function prototype or declaration is omitted. (Refer- page no. 338 in 'C.Sc with c++ 'by Sumita Arora class XI)
2. Function body appears after the function call(usually in main()) , then function prototype or declaration becomes mandatory. (Refer- page no. 338 in 'C.Sc with c++ 'by Sumita Arora class XI).
Parameters of function can be-
1. Passed by value - Hence original parameters are not effected by change of formal parameters.
2. Passed by reference - Hence original parameters are changed by change of formal parameters. & is prefixed in the parameter name.
3. Default parameters - Function call may miss the defaulted parameter, but if given default value will be overwritten.
NOTE- DEFAULTING OF PARAMETERS IS DONE FROM RIGHT TO LEFT.
4. Constant parameters- const qulifier appears in the parameter list. No change on this parameter is acceptable.

Function may return -
1. A value - In this case function call will be written with cout statement or will appear on the right hand side of assignment statement.
2. A reference - In this case function call will appear at the left hand side of the assignment statement.
NOTE- THIS IS USED TO RESET THE VALUE OF THE REFERNCE PASSED THRU FUNCTION.

Wednesday, April 2, 2008

ACTIVITIES OF COMPUTER SCIENCE DEAPRTMENT


COMPUTER SCIENCE DEPARTMENT HOSTS VARIOUS EVENTS THROUGH-OUT THE YEAR. STUDENTS AND TEACHERS WORK TOGETHER TO MAKE IT A GREAT SUCCESS



  • ORGANISING IT FEST - ATHENEAUM - 2007 ON THE THEME- " WATER A LIFE-LINE"







  • ORGANISING CYBER OLYMPIAD

Since 2001 Cyber Olympiad has been a regular feature of the school. It is conducted for classes III to XII every year . Many students had cleared the second level and were awarded a merit certificates and medals. Such competitions, stimulate, motivate, inculcate and enhance the logical aptitude. It also develops problem-solving capabilities of students.



  • ORGANISING INTERNATIONAL INFORMATICS OLYMPIAD

IIO was conducted for classes I to XII for the first time. 1223 students appeared in the exam. Mock test was conducted for class I students. The response was overwhelming. Many students had cleared to the second level. The Rank holders had received merit certificates and medals. Students with international ranking(1-15) were awarded a parker pen. Our school Principal Mrs. Sneh Verma was awarded the ‘BEST PRINCIPAL’ and ‘ The School IIO coordinator Mrs. Vandita Munjal was awarded the ‘BEST COORDINATOR ‘ for the school’s excellent performance in IIO,2007. This award comprised of a shield, merit certificate and a cash prize.



  • PUBLISHING IT MAGZINE - PUSHPANJALI BYTES