Introduction To C - Programming Language
Introduction To C - Programming Language
Introduction to C++
Contact
Sunday, November 20, 2022
1
C++ Programming Language 11/20/2022
statement.
One dimensional array I.
One dimensional array II.
Two dimensional array I.
Two dimensional array II.
Struct I
4
Struct II
2
C++ Programming Language 11/20/2022
Module Resources
Book
Sunday, November 20, 2022
3
C++ Programming Language 11/20/2022
Lecture one
Introduction to C++ Programming
C++ Programming Language
Language
4
C++ Programming Language 11/20/2022
10001011011000010001000001001110
Software can be represented by printed words
and symbols that are easier for humans to
manage than binary sequences.
Tools exist that automatically convert a higher-
level description of what is to be done into the 10
required lower-level code.
5
C++ Programming Language 11/20/2022
sentences.
Programmers must follow strict syntax rules to create
well-formed computer programs.
Only well-formed programs are acceptable and can be
compiled and executed.
Some syntax-aware editors can use colors or other
special annotations to alert programmers of syntax 12
errors before the program is compiled.
6
C++ Programming Language 11/20/2022
14
7
C++ Programming Language 11/20/2022
What is C++?
The C++ programming language
8
C++ Programming Language 11/20/2022
17
Screen output
Enjoy yourself with C++!
18
9
C++ Programming Language 11/20/2022
C++ Program
The first line begins with the number
symbol, #, which indicates that the line is
intended for the pre-processor. The pre-
processor is just one step in the first
translation phase and no object code is created
at this time.
C++ Programming Language
10
C++ Programming Language 11/20/2022
C++ Program
The word stream indicates that the information
involved will be treated as a flow of data.
Predefined names in C++ are to be found in the
std (standard) namespace.
The using directive allows direct access to the names
C++ Program
In our example the function main() contains two statements. The
first statement cout << "Enjoy yourself with C++!" << endl;
outputs the text string Enjoy yourself with C++! on the screen.
The name cout (console output) designates an object
responsible for output.
The two less-than symbols, <<, indicate that characters are
C++ Programming Language
11
C++ Programming Language 11/20/2022
C++ Program
C++ is case sensitive. All commands in C
must be lowercase.
C++ has a free-form line structure.
End of each statement must be marked with
Data Structure
a semicolon. Multiple statements can be on
the same line.
White space is ignored. Statements can
continue over many lines.
23
Comments
This example also introduces comments. Strings
enclosed in /* . . . */ or starting with // are interpreted as
comments.
EXAMPLES:
/* I can cover
several lines */
// I can cover just one line
Data Structure
12
C++ Programming Language 11/20/2022
Exercise (1)
Write a C++ program that outputs the following
text on screen:
Oh what
a happy day!
Oh yes,
what a happy day!
Data Structure
25
Exercise (2)
The following program contains several errors:
*/ Now you should not forget your glasses //
#include <stream>
int main
{
cout << "If this text",
Data Structure
13
C++ Programming Language 11/20/2022
Exercise (3)
What does the C++ program output on screen?
#include <iostream>
using namespace std;
int main(){
cout << endl << "Dear reader, "
<< endl << "have a ";
Data Structure
cout << “break!" << endl;
return 0;}
27
Solution (1)
Exercise 1
#include <iostream>
using namespace std;
int main()
{
cout << " Oh what " << endl;
Data Structure
14
C++ Programming Language 11/20/2022
Solution (2)
Exercise 2
The corrected places are underlined.
Data Structure
29
Solution (3)
Exercise 3
The screen output begins on a new line:
Dear reader,
have a BREAK!
Data Structure
30
15
C++ Programming Language 11/20/2022
Thank you
Data Structure
31
16