Professional Documents
Culture Documents
Instructor Led C Online Webinar Session - 3 PDF
Instructor Led C Online Webinar Session - 3 PDF
WEBINAR
COACHING
BY APTUTS.COM
EMAIL: LEARN@APTUTS.COM
ABOUT ME
Bachelor's Degree in Computer Science Engineering
Software Engineer in IT Industry & Teaching Experience
7 Years of IT experience in various technologies
Expertise in C, C++, Application Development, Manual Testing, Web Automation Testing, Mobile
Automation Testing, Website Designing, PHP and VBScript
Founder of LearnCOnline.com, LearnCPPOnline.com and Aptuts.com
Contact Info: prashant@aptuts.com
COURSE CURRICULUM
Following topics would be covered:
Overview
Fundamentals and Control Statements
Data Input and Output in C
Functions and Function Overloading
DEFINING OF FUNCTIONS
A function definition has two principal components:
1.
2.
c = a + b;
return c;
}
ACCESSING OF FUNCTIONS
A function can be accessed (i.e., called) by specifying its name, followed by a list of arguments enclosed
in parentheses and separated by commas as shown below.
function_name(int a, int b);
If the function call does not require any arguments, an empty pair of parentheses must follow the
name of the function as shown below.
function_name();
The function call may be a part of a single expression (such as an assignment statement), or it may be
one of the operands within the more complex expression as shown below.
int returnedvalue = function_name();
int c = 3 * function_name() + 5;
The arguments appearing in the function call are referred to as actual arguments, in contrast to the
formal arguments that appear in the first line of the function definition.
In normal function call, there will be one actual argument for each formal argument. The actual
arguments may be expressed as constants, single variables or more complex expressions.
However, each actual arguments must be of the same data type as its corresponding formal
argument.
c = a + b;
return c;
}
We can access the above defined function as shown below:
FUNCTION PROTOTYPES
All the functions in C (which are used first and defined later in the program) need to be prototyped.
Function prototypes are usually written at the beginning of the program, ahead of any programmer-defined functions (including main()).
The general form of a function prototype is:
data-type function_name(type 1 arg 1, type 2 arg 2, ..., type n arg n);
Where,
data-type represents the data-type of the item that is returned by the function,
function_name represents the function name, and
type 1, type 2, , type n represents the data-type of the arguments arg 1, arg 2, , arg n.
Notice that a function prototype resembles the first line of a function definition (though a function prototype ends with a semicolon).
Use of function prototypes in C offers following advantages:
Prototypes enables the compilers to provide stronger type checking
Because of the use of prototypes, the compiler can find and report any questionable type conversions between the arguments used to
call a function and the types of its (function;s) parameters
Because of the use of prototypes, the compiler can also catch differences between the number of arguments used to call a function and
the number of parameters in the functions
Function prototypes help to trap bugs before they occur
Function prototypes help to verify that the program is working correctly by not allowing functions to be called with mismatched
arguments
passes the value 5000 to principal and 7 to period and then lets the function use the default value of 0.15 for rate.
One more important point to note here is that only the trailing arguments can have default values.That is, we must add defaults
from right to left. We cannot provide a default values to a particular argument in the middle of the argument list.
Hence, the prototypes:
float amount(float principal = 5000, int period = 7, float rate);
float amount(float principal = 5000, int period, float rate = 0.15);
are invalid as they does not add defaults from right to left.
ARRAYS
An array can be defined as a sequence of data in memory, wherein all the data are of
the same type, and are placed in physically adjacent locations.
An array is a group of elements that share a common name, and that are differentiated from one
another by their positions within the array.
The position of each of these elements can be indicated by
means of a index as:
x[0] = 65;
x[1] = 33;
x[2] = 64;
x[3] = 88;
x[4] = 5;
Also, an array must be declared, since it is a type of variable. An array containing five elements, all
of which are integers, can be declared as follows:
int x[5];
ARRAYS (CONDT...)
Defining of 1-Dimensional Arrays in C++
In general terms, a 1-Dimensional array definition may be represented as:
storage-class data-type array[expression];
Where storage-class refers to the storage class of the array,
data-type is the data type,
ARRAYS (CONDT...)
Defining of Multi-Dimensional Arrays in C++
In general terms, Multi-Dimensional array definition may be represented as:
storage-class data-type array[expression 1][expression 2]...[expression n];
Where storage-class refers to the storage class of the array,
data-type is the data type,
Remember that the storage-class is optional; default values are automatic for arrays that are
defined within a function or a block, and external for arrays that are defined outside of a
function.
ARRAYS (CONDT...)
Defining of Multi-Dimensional Arrays in C
In general terms, Multi-Dimensional array definition may be represented as:
storage-class data-type array[expression 1][expression 2]...[expression n];
Where storage-class refers to the storage class of the array,
data-type is the data type,
Remember that the storage-class is optional; default values are automatic for arrays that are
defined within a function or a block, and external for arrays that are defined outside of a
function.
ARRAYS (CONDT...)
Defining of Multi-Dimensional Arrays in C
In general terms, Multi-Dimensional array definition may be represented as:
storage-class data-type array[expression 1][expression 2]...[expression n];
Where storage-class refers to the storage class of the array,
data-type is the data type,
Remember that the storage-class is optional; default values are automatic for arrays that are
defined within a function or a block, and external for arrays that are defined outside of a
function.
THANK YOU
Web: www.aptuts.com
Email: learn@aptuts.com
Social: www.facebook.com/aptuts