complete c++ basic
complete c++ basic
Deepak Sharma
Assistant Professor
BSBE, IIT Roorkee
Getting started
One needs:
Standard header
Preprocessor directive; Standard
mainC++
Where
Data – the
function;
type onebegins
-program
lib and only one
integer Output operator
Standard output
Program body
stream
“Hello, World” Program – Take 2
Characters and Literals
newline character
\n
horizontal tab \t
print special characters \”
Variables and Constants
Deepak Sharma
Assistant Professor
BSBE, IIT Roorkee
Data Types
• Integers
– 11 types
– int, char and bool
modulus/remainder
operator
Floating-Point Arithmetic
Composite Assignment
Operators
sizeof Operator
Type Conversion
Integer Overflow
Floating-point Overflow
Round-off Error
C++ Programming (Conditions)
Deepak Sharma
Assistant Professor
BSBE, IIT Roorkee
if Statement
if..else Statement
Keywords
Comparison Operators
Standard Input & Common
Error
Find Minimum of 3 Integers
Statement Blocks
Compound Conditions & Short-
circuiting
else..if Statement
Conditional Expression
Operator
C++ Programming (Loops)
Deepak Sharma
Assistant Professor
BSBE, IIT Roorkee
while Loop
do..while Loop
for Loop
Terminating a Loop
Terminating a Program
continue Statement
Descending for Loop
Pseudo-random Numbers
Random Numbers
C++ Programming (Functions)
Deepak Sharma
Assistant Professor
BSBE, IIT Roorkee
Standard C++ Library
Functions
head
body
Function Declarations & Definitions
declaration
definition
Separate Function Compilation
void Function & Passing by
Reference
Passing by Value vs. Passing by
Reference
Passing By Value Passing By Reference
int x; int& x;
Parameter x is a local variable Parameter x is a local reference
Duplicate of argument Synonym of argument
Cannot change the argument Can change the argument
Argument may be a constant, a Argument must be a variable
variable or an expression
Argument is read-only Argument is read-write
C++ Programming (Arrays)
Deepak Sharma
Assistant Professor
BSBE, IIT Roorkee
Arrays