Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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
CONTROL STATEMENTS
Control statements alter the flow of execution of the programs. Control statements can be
broadly divided into three categories:
Decision-making or Conditional Statements (Branching and Selection)
o if statement
o if-else statement
o switch statement
Loop Statements
o for statement
o while statement
o do-while statement
IF STATEMENT
The if statement is used to express the conditional expressions. If the given condition is true
then it will execute the statements otherwise it will execute the optional statements.
The basic simple structure of the if statement is shown below:
if (expression)
{
//set of statements
}
The expression must be placed in round brackets as shown above. In this form, the set of
statements would be executed only if the expression has a non-zero value (i.e.,
ifexpression is true). If the expression has a value zero (i.e., if expression is false), then
the set of statements would be ignored by C compiler. The set of statements are skipped
and the execution continues with the next statements.
IF-ELSE STATEMENT
if statement is most commonly used with the following format:
if(expression){
statement 1
}
else{
statement 2
}
In this case, either of the two statements are executed depending upon the value of the
expression. If the expression has a non-zero value (i.e., if the expression is true), then
statement1 will be executed. Otherwise (i.e., if expression is false), statement2 will be
executed.
SWITCH STATEMENT
The switch statement is a special multi-way decision maker that tests whether an expression matches one of the
number of constant values accordingly. switch statement allows the user to choose a statement or a group of
statements among several alternatives. The switch statement is useful when a variable is compared with different
constants, and in case it is equal to a constant, a set of statements would be executed.
The general form of the switch statement is as follows:
switch (expression) {
case constant 1:
statement;
case constant 2:
statement;
..........
.........
case constant n:
statement;
default:
statement;
}
FOR STATEMENT
The for statement or for loop is useful while executing a statement multiple number of times.
The for loop is the most commonly used statement in C. This loop consists of three expression:
The first expression is used to initialize the index value
The second expression is used to check whether or not the loop is to be continued again
The third expression is used to change the index value for further iteration
WHILE STATEMENT
The second type of loop, the while loop, is used when we are not certain that the loop will be
executed. After checking whether the initial condition is true or false and finding it to be true,
then only while loop will enter into the loop operations.
The general form of the while loop for a single statement is:
while(expression){
statement;
}
The expression can be any valid C++ language expression including the value of a variable, an
unary or a binary expression, or the value returned by a function.The statement can be
single or compound statement.
The statement will be executed repeatedly, as long as the expression is true (i.e., as long
as expression has a non zero value). statement must include some features that eventually
alters the value of the expression, thus providing a stopping condition for the loop.
DO-WHILE STATEMENT
The do-while loop is another repetitive loop used in C programs.
When a loop is constructed using the while statement, the test for continuation of the loop is
carried out at the beginning of each pass. Sometimes, however, it is desirable to have a loop
with the test for continuation at the end of each pass. This can be accomplished by means
of do-while statement.
The general form of the do-while statement is:
do{
statements;
}while(expression);
The statement will be executed repeatedly, as long as the value of expression is true (i.e., is
non-zero). Notice that statement will always be executed at least once, since the test for
repetition does not occur until the end of the first pass through the loop. The statement can
be either simple or compound. It must include some feature that eventually alters the value
of expression so that the looping action can terminate.
BREAK STATEMENT
The break statement is used to terminate loops or to exit from a switch. It can be used within
a for, a while, a do-while or a switch statement.
The break statement is written simply as:
break;
without any embedded expressions or statements.
The break is a keyword in the C program and the semicolon must be inserted after
the break statement.
We have already seen the use of break statement within the example of switch statement.
The break statement causes a transfer of control out of the entire switch statement, to the
first statement following the switch statement.
CONTINUE STATEMENT
The continue statement is used to bypass the remainder of the current pass through a loop. The
loop does not terminate when a continue statement is encountered. Rather, the remaining
loop statements are skipped and the computation proceeds directly to the next pass through
the loop.
The continue statement can be included within a for, a while or a do-while statement.
The continue statement is written simply as:
continue;
without any embedded expressions or statements.
The continue is a keyword in the C program and the semicolon must be inserted after
the continue statement.
GOTO STATEMENT
The goto statement is used to alter the normal sequence of the program execution by
transferring control to some other part of the program.
In its general form, the goto statement is written as:
goto label;
Where label is an identifier that is used to label the target statement to which control will be
transferred.
Control may be transferred to any other statement within the program. The target statement
must be labelled, and the label must be followed by a colon.
Thus, the target statement will appear as:
label: statement
Each labeled statement within the program must have a unique label; i.e., no two statements can
have the same label.
THANK YOU
Web: www.aptuts.com
Email: learn@aptuts.com
Social: www.facebook.com/aptuts