INTRODUCTION TO C++
What is C++?
• C++ was developed by Bjarne Stroustrup, as an extension to the C
language.
• C++ is a cross-platform language that can be used to create high-
performance applications.
• C++ gives programmers a high level of control over system resources
and memory.
Uses of C++ language
• To design operating system.
• To develop games.
• Design web browser.
• To develop of new language.
C++ data types
Primary data type int, float, char, void
User defined data type
structure, union, class,
enumeration
Derived data type
array, function, pointer,
reference
Keywords in C++
asm default For private struct unsigned
auto delete Friend protected switch using
bool do Goto public template virtual
break double If register this void
case dynamic_cast inline reinterpret_cast throw volatile
catch else int return true wchar_t
char enum long short try while
class explicit mutable signed typedef
const extern namespace sizeof typeid
const_cast false new static typename
continue float operator static_cast union
Tips in writing a program
• The machine problem must be analyzed through identification of
the requirement.
• Interpret the machine problem through Pseudocode algorithm and
flowchart symbols.
• Observe the technical writing structure in writing a program.
• The output of the program must achieve a user-friendly interface.
Sample
#include <iostream>
using namespace std;
int main()
{
//display message
cout<<"Welcome to C++ Programming!n";
return 0;
}
1
2
3
4
5
6
7
8
9
10
Welcome to C++ Programming!
Sample OutputSource Code
Line 1:
#include <iostream>
This is a directive that instructs the preprocessor to include a section
of standard C++ code, known as header iostream that allows to
perform standard input and output operations.
Line 2:
using namespace std;
This code instructs the C++ compiler to use the standard C++
library. The identifier cout and cin are part of the standard library.
Line 4:
int main()
This line initiates the declaration of a function. The function
named main is a special function that is called when the
program is run. The execution of all C++ programs begins with
the main function, regardless of where the function is actually
located within the code.
Line 6:
//display message
This is a comment line. Comments do not have any effect on the
behavior of the program. Programmers can use them to create short
explanation or description of the codes.
Line 7:
cout << “Welcome to C++ Programming!n”;
cout represents the standard output stream in C++. The
meaning of the statement above is to insert a series of characters
(in this case the Welcome to C++ Programming! characters)
into the screen.
Line 7:
n
In printing the output, notice that it has n. This special character is
an escape sequence or escape character. Escape characters are
preceded by a backslash (). n indicates a new line. Some of the
escape characters are t which indicates a horizontal tab,  which is
used to print out a backslash () and ” which is used to print out a
double quote.
Line 8:
return 0;
The return statement causes the main function to finish. Return may be
followed by a return code (in our example is followed by the return
code 0). A return code of 0 for the main function is generally
interpreted as the program worked as expected without any errors
during its execution. This is the most usual way to end a C++ console
program.
Thank You!

AS TASKS #8

  • 1.
  • 2.
    What is C++? •C++ was developed by Bjarne Stroustrup, as an extension to the C language. • C++ is a cross-platform language that can be used to create high- performance applications. • C++ gives programmers a high level of control over system resources and memory.
  • 3.
    Uses of C++language • To design operating system. • To develop games. • Design web browser. • To develop of new language.
  • 4.
    C++ data types Primarydata type int, float, char, void User defined data type structure, union, class, enumeration Derived data type array, function, pointer, reference
  • 5.
    Keywords in C++ asmdefault For private struct unsigned auto delete Friend protected switch using bool do Goto public template virtual break double If register this void case dynamic_cast inline reinterpret_cast throw volatile catch else int return true wchar_t char enum long short try while class explicit mutable signed typedef const extern namespace sizeof typeid const_cast false new static typename continue float operator static_cast union
  • 6.
    Tips in writinga program • The machine problem must be analyzed through identification of the requirement. • Interpret the machine problem through Pseudocode algorithm and flowchart symbols. • Observe the technical writing structure in writing a program. • The output of the program must achieve a user-friendly interface.
  • 7.
    Sample #include <iostream> using namespacestd; int main() { //display message cout<<"Welcome to C++ Programming!n"; return 0; } 1 2 3 4 5 6 7 8 9 10 Welcome to C++ Programming! Sample OutputSource Code
  • 8.
    Line 1: #include <iostream> Thisis a directive that instructs the preprocessor to include a section of standard C++ code, known as header iostream that allows to perform standard input and output operations.
  • 9.
    Line 2: using namespacestd; This code instructs the C++ compiler to use the standard C++ library. The identifier cout and cin are part of the standard library.
  • 10.
    Line 4: int main() Thisline initiates the declaration of a function. The function named main is a special function that is called when the program is run. The execution of all C++ programs begins with the main function, regardless of where the function is actually located within the code.
  • 11.
    Line 6: //display message Thisis a comment line. Comments do not have any effect on the behavior of the program. Programmers can use them to create short explanation or description of the codes.
  • 12.
    Line 7: cout <<“Welcome to C++ Programming!n”; cout represents the standard output stream in C++. The meaning of the statement above is to insert a series of characters (in this case the Welcome to C++ Programming! characters) into the screen.
  • 13.
    Line 7: n In printingthe output, notice that it has n. This special character is an escape sequence or escape character. Escape characters are preceded by a backslash (). n indicates a new line. Some of the escape characters are t which indicates a horizontal tab, which is used to print out a backslash () and ” which is used to print out a double quote.
  • 14.
    Line 8: return 0; Thereturn statement causes the main function to finish. Return may be followed by a return code (in our example is followed by the return code 0). A return code of 0 for the main function is generally interpreted as the program worked as expected without any errors during its execution. This is the most usual way to end a C++ console program.
  • 15.