Showing posts with label Functions. Show all posts
Showing posts with label Functions. Show all posts
Control Unit
How many times have you kept your book open with your eyes fixed on it and not read a single word? This happens because the Control Unit of your brain does not allow your eyes to provide an input at a given point of time.
A Control Unit is that part of the computer, which makes the ALU and Memory work in synchronization with the data. It is a part of the central processing unit which directs the sequence of operations, interprets coded instructions and sees to the execution of program instructions. In order to process instructions sequentially, the CU goes through the following steps:
1. Retrieves an instruction from the processor memory.
2. Determines the action to be taken, on being requested.
3. Directs the CPU to perform operations.
4. Determines whether the operations\ was carried out properly or not.
5. Displays an error message to the user if the operation was not carried out properly - through the output device.
6. Stores the result in memory for further processing, if error free.
7. Determines the location of the next instruction.
Date and Time Functions in VB
Not only does Visual Basic let you store date and time information in the specific Date data type, it also provides a lot of date- and time-related functions. These functions are very important in all business applications and deserve an in-depth look. Date and Time are internally stored as numbers in Visual Basic. The decimal points represents the time between 0:00:00 and 23:59:59 hours inclusive.
The system's current date and time can be retrieved using the Now, Date and Time functions in Visual Basic. The Now function retrieves the date and time, while Date function retrieves only date and Time function retrieves only the time.
Constants, Data Type Conversion, Visual Basic Built-in Functions
Constants are named storage locations in memory, the value of which does not change during program Execution. They remain the same throughout the program execution. When the user wants to use a value that never changes, a constant can be declared and created. The Const statement is used to create a constant. Constants can be declared in local, form, module or global scope and can be public or private as for variables. Constants can be declared as illustrated below.
Public Const gravityconstant As Single = 9.81
Predefined Visual Basic Constants
The predefined constants can be used anywhere in the code in place of the actual numeric values. This makes the code easier to read and write. LEARN MORE >>>>>
Function Overloading
When several functions declarations are specified for a single function name in the same scope, the function name is said to be overloaded. C++ distinguishes functions having the same name by their number and tyoe if arguments.
A function name having several definitions that are differentiable by the number or types of their arguments is known as function overloading.
Overloading improves the readibility of a program by reducing namespace pollution. It makes the language extensible. It is used in inheritence and abstraction.
Math & Conversion Functions
These functions are used for various algebric and trignometric operations:
1. abs()
The function abc() calculates the absolute vlaue of an integer. The argument to this function is an integer. It has a prototype in the header file math.h
2. fabs()
The function fabs() returns the absolute value of an argument. The argument to this function is a number of type float or double. It has a prototype in the header file math.h LEARN MORE>>
1. abs()
The function abc() calculates the absolute vlaue of an integer. The argument to this function is an integer. It has a prototype in the header file math.h
2. fabs()
The function fabs() returns the absolute value of an argument. The argument to this function is a number of type float or double. It has a prototype in the header file math.h LEARN MORE>>
Character and String functions
These functions are used for manipulating characters.
1. isalnum()
This functions carries out the test "Is the character alphanumeric?". An alphanumeric character is a letter of either lower or upper-case, or a digit. It has a prototype in the header file ctype.h. The argument to this function is a character represented as an integer.
The function isalnum() returns a non-zero value if the character is alphanumeric and zero if it is not so.
2. isdigit()
This function carries out the test "Is the character a digit?". It has a prototype in the header file ctype.h. The argument to this function is also characte represented as an integer.
The function isdigit() returns a non-zero value if the character is a digit and a zero if it is not so.
LEARN MORE >>
1. isalnum()
This functions carries out the test "Is the character alphanumeric?". An alphanumeric character is a letter of either lower or upper-case, or a digit. It has a prototype in the header file ctype.h. The argument to this function is a character represented as an integer.
The function isalnum() returns a non-zero value if the character is alphanumeric and zero if it is not so.
2. isdigit()
This function carries out the test "Is the character a digit?". It has a prototype in the header file ctype.h. The argument to this function is also characte represented as an integer.
The function isdigit() returns a non-zero value if the character is a digit and a zero if it is not so.
LEARN MORE >>
Header Files
Various library functions are available in C and C++ in the form of header files. A hheader file is a file containing a list of all the functions and structures that will be used by a file ( for C++, classes and methods).
Header files provide function prototypes and declarations for library functions. Data types and constants used with the library functions are also defined in them.
In order to include the required header files in the program, angle brackets '< ' and '>' are used. the angle brackets prompt the C++ compiler to search for the header file in its include directory. LEARN MORE>>
Header files provide function prototypes and declarations for library functions. Data types and constants used with the library functions are also defined in them.
In order to include the required header files in the program, angle brackets '< ' and '>' are used. the angle brackets prompt the C++ compiler to search for the header file in its include directory. LEARN MORE>>
Functions.....cont(2)
Default Values in Arguments
When defining a function we can specify default values that will be taken into acount by the argument variables in case these are avoided when the function is called. This is done by simply assigning a value to the arguments when declaring the function. These values will be used if that parameter is not passed when when the function is called.
If the value of that parameter is finally set when calling the dafault value, it is stepped up. For eg: LEARN MORE>>
When defining a function we can specify default values that will be taken into acount by the argument variables in case these are avoided when the function is called. This is done by simply assigning a value to the arguments when declaring the function. These values will be used if that parameter is not passed when when the function is called.
If the value of that parameter is finally set when calling the dafault value, it is stepped up. For eg: LEARN MORE>>
Functions.....cont(1)
Declaring Vs Defining a function
The syntax of a function declaration is identical to the header of a function definistion, except that:
It does not include a statement for the function. Which means that it does not include the statement body with all the instructions that are usually enclosed within key brackets { }.
It ends with a semicolon(;).
In the argument enumeration, it is enough to write the type of each argument. The inclusion of a name for each argument is recommended, though optional as in the definition of a standard function.
Calling a function
In order for a function to be used, it must be called by another function. To call a function, one enters the name of the function followed by a matching pair of parentheses inside which is the list of parameter values to be passed to the function. The list is in the same order as in the declaration. The parameters included in function declarations are called formal parameters while the parameters listed in a function call are called the actual parameters.
For example, in order to invoke a function whose prototype is of the following format:
flaot volume(float, float,float);
the function call statement can be used:
volume(l,b,h);
where l,bh are float variables. LEARN MORE>>
The syntax of a function declaration is identical to the header of a function definistion, except that:
It does not include a statement for the function. Which means that it does not include the statement body with all the instructions that are usually enclosed within key brackets { }.
It ends with a semicolon(;).
In the argument enumeration, it is enough to write the type of each argument. The inclusion of a name for each argument is recommended, though optional as in the definition of a standard function.
Calling a function
In order for a function to be used, it must be called by another function. To call a function, one enters the name of the function followed by a matching pair of parentheses inside which is the list of parameter values to be passed to the function. The list is in the same order as in the declaration. The parameters included in function declarations are called formal parameters while the parameters listed in a function call are called the actual parameters.
For example, in order to invoke a function whose prototype is of the following format:
flaot volume(float, float,float);
the function call statement can be used:
volume(l,b,h);
where l,bh are float variables. LEARN MORE>>
Functions
A Function is a named unit of a group of program statements. This unit can be invoked from other parts of the program. With the help of a function the program becomes easy to handle and ambiguity is avoided when dealing with a small part of the program. The size of the program also reduced by the use of functions in a prgram.
Functions are pieces of codes that do exactly what their names indicates - performs a task or function in your program. Functions are good because they let you write a code that is modular. Modular code is easy to debug and easy to maintain. In order to use a function, it has to be first declared and then defined. LEARN MORE>>
Functions are pieces of codes that do exactly what their names indicates - performs a task or function in your program. Functions are good because they let you write a code that is modular. Modular code is easy to debug and easy to maintain. In order to use a function, it has to be first declared and then defined. LEARN MORE>>
I/O Functions
Input and output devices play a key role indata processing. the first phase of processing data is input. Data is accepted in the form of input and output is generated after processing data. C++ language does not facilitate input and output with the help of keywords. Input and output operations are performed with the help of library functions. There are header files which help in performing input/output activities.
Header Files in C++
The list of keywords in C++ does not include functions. However, built in functions are available with C++ library header files. Declarations of function prototypes, classes etc. are provided by header files. The function prototypes are pre-declared before using them in the program. LEARN MORE>>
Header Files in C++
The list of keywords in C++ does not include functions. However, built in functions are available with C++ library header files. Declarations of function prototypes, classes etc. are provided by header files. The function prototypes are pre-declared before using them in the program. LEARN MORE>>
Subscribe to:
Posts (Atom)
