You are on page 1of 23

C++

MICHEL BOLO

INTRODUCTION
C++
is
a
middle-level
programming language developed by
Bjarne Stroustrup starting in 1979 at
Bell Labs. C++ runs on a variety of
platforms, such as Windows, Mac OS,
and the various versions of UNIX.

SAMPLE PROGRAM
#include <iostream>
using namespace std;
Int main() {
cout << "Hello World";
return 0;
}

C++ Program
Structure:
Let us look at a simple code
that would print the words
Hello World.

The C++ language defines several headers, which


contain information that is either necessary or
useful to your program. For this program, the
header <iostream> is needed.
The line using namespace std; tells the compiler
to use the std namespace. Namespaces are a
relatively recent addition to C++.
The next line // main() is where program
execution begins. is a single-line comment
available in C++. Single-line comments begin
with // and stop at the end of the line.
The line int main() is the main function where
program execution begins.
The next line cout << "This is my first C++
program."; causes the message "This is my first
C++ program" to be displayed on the screen.
The next line return 0; terminates main( )function
and causes it to return the value 0 to the calling
process.

C++ Identifiers:
A C++ identifier is a name used to identify a
variable, function, class, module, or any
other user-defined item. An identifier starts
with a letter A to Z or a to z or an underscore
(_) followed by zero or more letters,
underscores, and digits (0 to 9).
C++ does not allow punctuation characters
such as @, $, and % within identifiers. C++
is a case-sensitive programming language.
Thus, Manpower and manpower are two
different identifiers in C++.
Example:

C++ Keywords:
The following list shows the
reserved words in C++.
These reserved words may
not be used as constant or
variable or any other
identifier names.

asm
else new this auto
enum
operator throw bool explicit
private
true break
export
protected
try
case
extern
public
typedef
catch
false register
typeid char
float
reinterpret_cast typename
class
for
return union const friend
short unsigned const_cast goto signed
using
continue
if
sizeof virtual
default
inline static void delete
int static_cast
volatile do long struct
wchar_t double mutable
switch
while dynamic_cast
namespace
template

Programming
Environment
Programming Language
Editor
Dev C C++
Where to download
http://bloodshed.net/
the editor?

Course Description
This course focuses on the basic concepts of
programming using a high-level language. Problemsolving techniques and logic formulation are the
highlights of the course.
Topics include algorithms, basic control structures, static
memory allocations, top-down design, and procedural
abstraction. Students will be formulating logic flows for
solving problems using flowcharts and pseudo codes.
The programming language used is C. This course may
also include introduction to arrays (optional).

Terminal Objectives
At the end of the semester, the students are expected to:
Break down logically a problem into smaller parts in order to solve it.
Formulate algorithms that would specifically address all the
requirements of problem solving.
Design flowcharts that describe the logical flow of data and processes
to solve the problem.
Create programs using the basic control structures like selection, and
iteration.
Solve problems using top-down approach, and procedural abstraction.
Develop within them logical and analytical thinking necessary for
making programs.
Develop the values of hard work and perseverance as essential values
for success.

Course Requirements
Solutions to Machine
Problems
Periodical Exams / Laboratory
Examination
Topic Reporting
Final Project

Course Outline 1
Introduction to Computers and
Languages

Computer Organization
Evolution of operating systems
Machine, assembly, and high-level languages
History of C
C Standard Library
C++ and Java
Other High-level languages
Structured programming
C Program Integrated Development Environment
Hardware trends

Course Outline 2
Introduction to C Programming

Simple C Program: Printing a line of text


Simple C Program: Adding two integers
Lexical Elements

Keywords
Identifiers
Operators
Punctuators
Constants
String constants
Comments

Memory concepts
Arithmetic in C
Equality and relational operators

Course Outline 3
Structured Program
Development in C

Algorithms
Pseudo code
Control structures
The if selection structure
The if/else selection structure
The while repetition structure
Formulating algorithms
Counter-controlled repetition
Sentinel-controlled repetition
Nested control structures
Assignment operators
Increment and decrement operators

Course Outline 4
C Program Control

Essentials of repetition
Counter-controlled repetition
The for repetition structure
Notes and observations
Examples
The switch multiple-selection structure
The do/while repetition structure
The break and continue statements
Logical operators
Confusing equality and assignment operators
Structured programming summary

Course Outline 5
C Functions

Top-down design
Program modules in C
Math library functions
Functions
Function definition
Function prototypes
Header files
Calling functions
Random number generation
Storage classes
Scope rules
Recursion
Recursion vs. Iteration

Course Outline 6
C Arrays (optional)
Declaring arrays
Examples using arrays
Passing arrays to functions
Sorting arrays
Searching arrays
Multiple-subscripted arrays

How to succeed in the


subject?
Ways/Factors to consider:

Fun and learning


Do not pretend that you knows everything
Think always that I can do it
Read and research in advance
Practice and ask for some tips
YOU SHOULD HAVE GOALS to learn
Have initiatives, presence of mind, focus,
patience, and determination

Follow Up Assignment
Answer these following questions:

What is programming?
What is computer programming?
Why do IT students needs to learn programming?
Enumerate some applications that are product of computer
programming

Where to write: short bond paper, computerized (1 page


only), copy the questions
Due: --In each question, please indicate the source/s for validation.

You might also like