This document provides an introduction to C++ programming language. It discusses that C++ was created in 1979 by Bjarne Stroustrup as an enhancement to C with additional object-oriented capabilities. Some key features of C++ include it being a mid-level, structured, portable language with a rich library and support for memory management, objects, and compilers. The document also covers C++ data types, variables, arrays, strings, control flow structures like if/else and loops, and functions.
2. INTRODUCTION AND HISTORY
• C++ language was created by bjarne stroustroup
and his team in 1979 in Bell laboratory of AT&T
( American Telephone & Telegraph ) located in U.S.A.
• When this language was created it was not directly
called as C++ instead it was called as “C with classes”
3. • Due to the limitations of C programming language
bjarne stroustroup and his team added lots of feature
mainly Object Oriented Programming (OOP) language.
• In 1983 they named C with class as C++ (++ is operator
in C language) called as increment operator which means
incrementation of C language.
4. C++ FEATURES
• Simple
• Machine Independent or Portable
• Mid level programming language
• Structured programming language
• Rich library
• Memory management
• Oject Oriented
• Compiler based
5. TYPES AND VARIABLES
DATA TYPES
Boolean Characters Integers Float
Variables are used with the data types, it is generally used to store values
Following is the syntax to define Variables
Syntax: Example:
Data type VariableName; int data;
6. ARRAYS
Arrays can be defined as group of collection Of similar kind of elements
Array elements are stored at contiguous memory location
Syntax for array declaration :
Data type Array_name [No. of elements ]
Example : int a [10]
7. STRINGS
• Strings are defined as group of Characters
• It is used to represent text in program and to manipulate it
example: String str = “ Geeks0 “
• In C++ there are 2 ways to create a string
1) C style string
2) Creating string object
8. IF ELSE
• If-else are two conditional statements , which are generally used when we want to run the code
based on some conditions .
• The code inside if statement runs , if the condition of if statement is true.
if (number ==10 )
{
cout << “ you got it “;
}
else
{
cout << “ Not this one”;
}
9. FOR LOOP
• For loop are used in C++ to repeat the
execution of code , instead of repeating
the code again and again.
• the syntax in for loop has three parts
For ( initialization ; condition ; inc/dec )
{
body
}
10. While loop
• while loops are used in C++ when we don’t
know the excat number of times the code
should repeat . It repeats the statement till
the given condition is true
• The syntax of while loop
while ( condition )
{
body
}
11. Functions
• Functions in C++ is a group or collection of statements that are designed to
perform specific task.
• We can also pass arguments to the function , and it can be invoked whenever
we want
• syntax:
type function- name (parameters….)
{
statement
}