0% found this document useful (0 votes)
9 views38 pages

1. Comp Prog Recap

Uploaded by

shiaaarin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views38 pages

1. Comp Prog Recap

Uploaded by

shiaaarin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

main.cpp sample.

cpp

Computer
2
3

Programming Recap
4
5 {
6
7 <Presented by: Grethel Einstein Bernardino>
8
9
10 }
11
12
13
14

C++ Programming Language


main.cpp sample.cpp

1 Table Of ‘Contents’ {
2
3
4 01 C++ Overview 06 Keywords
5
6 02 C++ Application 07 Basic Operators
7
8 03 Basic C++ syntax
08 Basic Input/Output
9 Statement
10 04 Data Types
09 Using a code/text
11
12
05 Variables editor or an IDE
13 10 Codeblocks Installation
14 }
C++ Programming Language
main.cpp sample.cpp

01 {
1
2
3
4

[C++ Overview]
5
6
7

}
8
9
10
11
12
13
14

C++ Programming Language


main.cpp sample.cpp

1 What is C++? {
2 - one of the world's most popular programming languages
- a cross-platform/general language that can be used to create high-
3
performance applications.
4 - can be found in today's operating systems, Graphical User
5 Interfaces, and embedded systems (e.g: Operating systems, Web
6 browsers, Machine learning, Databases, IoT devices, Financial
7 tools, Flight software, Medical technology, Movie production,
Flight software).
8 - developed by Bjarne Stroustrup, as an extension to the C language
9 (a general-purpose, procedural, imperative computer programming
10 language developed in 1972 by Dennis M. Ritchie at the Bell
11 Telephone Laboratories to develop the UNIX operating system).
- an object-oriented programming language which gives a clear
12 structure to programs and allows code to be reused thru the use of
13 classes and objects, lowering development costs.
14 - gives programmers a high level of control over system resources and
memory

C++ Programming Language


main.cpp sample.cpp

1 Difference of Procedural and OOP{


2 Procedural programming is a programming paradigm that uses a linear or
3 top-down approach, while object-oriented programming is about creating
4 objects that contain both data and functions.
5
Object-oriented programming has several advantages over procedural
6 programming: faster and easier to execute, provides a clear structure
7 for the programs, helps to keep the C++ code DRY "Don't Repeat
8 Yourself", and makes the code easier to maintain, modify and debug
9
OOP makes it possible to create full reusable applications with less
10 code and shorter development time
11
12 The "Don't Repeat Yourself" (DRY) principle is about reducing the
13 repetition of code. You should extract out the codes that are common
for the application, and place them at a single place and reuse them
14
} instead of repeating it.

C++ Programming Language


main.cpp sample.cpp

02 {
1
2
3
4
5
6
7
[First C++
8
9
10
Application]
11

}
12
13
14

C++ Programming Language


main.cpp sample.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14

C++ Programming Language


main.cpp sample.cpp

03 {
1
2
3
4

[C++ Syntax]
5
6
7
8 < File extension: .cpp and it is case-sensitive>

}
9
10
11
12
13
14

C++ Programming Language


main.cpp sample.cpp

Improve program readability and do not cause the


1 computer to perform any action

2 Tells the preprocessor to include the contents of


the file <iostream>, which includes input/output
3 operations (such as printing to the screen).
4
There should be exactly one main
5 function only on a program. int
means that main "returns" an
6 integer value.
7 All statements must end with a
8 semicolon.

9 Code must be saved before


compiling.
10
Round shape beside filename
11 indicates code is not yet saved.
12
13 return 0, in this case, means that
the program terminated normally.
14

C++ Programming Language


main.cpp sample.cpp

04 {
1
2
3
4

[Data Types]
5
6
7
8 < An attribute associated with a piece of data
9 that tells a computer system how to interpret its
value >
10
11

}
12
13
14

C++ Programming Language


main.cpp sample.cpp

1 ‘Data Types’{
2
3 char string
<Consist of multiple or
4 < Single text character. sequence of characters.
5 Indicated with single Indicated with double
6 quotes ‘’> quotes “”>
7
int double
8
< Handles numbers
9 < Integer consist of
with decimal points
10 whole numbers >
or floating points>
11
12 bool float
13 < Represents 2 < similar to double but
14 } values: true (1) or
false (0)>
less precision and
requires less memory>
You may also use the auto keyword
C++ Programming Language which allows you to set the type of
the variable based on its value.
main.cpp sample.cpp

05 {
1
2
3
4

[Variables]
5
6
7
8 < A named location in memory. It is used to store
9 data or information >
10
11

}
12
13
14

C++ Programming Language


main.cpp sample.cpp

1
Declaration
2 declaring/defining of what type is a variable (to know what
3 operations can be done with it) and its name.
4
5 Syntax: dataType variableName;
Shortcuts: dataType variableName1, variableName2, variableName3;
6 dataType variableName1 = value, variableName2 = value;
7
8 Initialization
9 specifying an initial value for the variable using (=) the
assignment operator.
10
11 Syntax: variableName = value;
12
13 Note: A variable can change its value during the program by
being assigned to a new value.
14

C++ Programming Language


main.cpp sample.cpp

1 Variable Naming Convention {


2
3 a set of rules for choosing the character sequence to be
4 used on creating a variable name
5
6 May contain numbers, letters and underscores (_)
7 May start with a letter or underscore but it may
8 NOT start with a number.
9 It should not include any whitespaces and special
10 characters.
11 It should be properly named, defining its function.
12
13
14 }
C++ Programming Language
main.cpp sample.cpp

1 Name Casing Convention {


2
3 Rules how to capitalize words in code to make it easier to read
4 camelCase - The first letter of a word is lowercase, and
5 each subsequent word starts with a capital letter.
6 E.g.: firstName, lastName.
7 PascalCase - Similar to camel case, but the first letter of
8 each word is capitalized. E.g.: FirstName, LastName
9 snake_case - Words are separated by underscores,
10 and typically all letters are lowercase. E.g.:
11 first_name, last_name.
12 kebab-case - Words are separated with hyphens, and all
letters are typically lowercase. E.g.: first-name,
13
14 } last-name.

C++ Programming Language


main.cpp sample.cpp

06 {
1
2
3
4

[Keywords]
5
6
7
< also known as reserved words. Have special meaning
8
to the C++ compiler and are always written or typed
9 in lower cases. Keywords are words that the language
10 uses for a special purpose, such as cout, cin, void,
11 int, public, etc. It can’t be used for a variable
name or function name. >

}
12
13
14

C++ Programming Language


main.cpp sample.cpp

1 Table for C++ keywords; {


2
3
4
5
6
7
8
9
10
11
12 < Reference:
13 https://www.geeksforgeeks.or
14 } g/cpp-keywords/ >

C++ Programming Language


main.cpp sample.cpp

07 {
1
2
3

[Basic Operators]
4
5
6
7 < Operators are used to perform operations on
variables and values. And divided into 4
8
groups/types: Arithmetic, Assignment, Comparison
9 and Logical Operators>
10
11

}
12
13
14

C++ Programming Language


main.cpp sample.cpp

1 Arithmetic Operators {
2
< Used to perform common mathematical operations. >
3
4
5
6
7
8
9
10
11
12
13
14 }
C++ Programming Language
main.cpp sample.cpp

1 Comparison Operators {
2
< Used to compare two values. >
3
4
5
6
7
8
9
10
11
12
13
14 }
C++ Programming Language
main.cpp sample.cpp

1 Assignment Operators {
2
< Used to assign values to variables. >
3
4
5
6
7
8
9
10
11
12
13
14 }
C++ Programming Language
main.cpp sample.cpp

1 Logical Operators {
2
< Used to determine the logic between variables or values. >
3
4
5
6
7
8
9
10
11
12
13
14 }
C++ Programming Language
main.cpp sample.cpp

08 {
1
2
3

[Basic Input/
4
5
6
7
8 Output Statement]
9 < C++ comes with libraries that provide us with many
10 ways for performing input and output. In C++ input
and output are performed in the form of a sequence
11 of bytes or more commonly known as streams. >

}
12
13
14

C++ Programming Language


main.cpp sample.cpp

Input Stream Output Stream


1
2 < If the direction of flow of < If the direction of flow of
3 bytes is from the device bytes is opposite, i.e. from
4 (e.g: Keyboard) to the main main memory to device (display
memory then this process is screen) then this process is
5
called input.> called output.>
6
7 < Header files available in C++ for Input/Output operations are:
iostream, iomanip, fstream >
8
9 We’ll focus on iostream:
● Standard output stream (cout)
10
Instance of the ostream class. It is used to produce output on
11 the standard output device, using the insertion operator(<<).
12 ● Standard input stream (cin)
13 Instance of the class istream and is used to read input from
the standard input device. The extraction operator(>>) is used
14
along with the object cin for reading inputs.

C++ Programming Language


main.cpp sample.cpp

1
2 Variable declaration, for the
compiler to know the expected type
3 of data to be inputted Save inputted data on the variable.
4
5
6
7
8
9
10 Print the inputted number stored on the
11 variable or process/manipulate it.
cout means console out
12
13
14

C++ Programming Language


main.cpp sample.cpp

09 {
1
2
3

[Using a code/
4
5
6
7
8 text editor or
an IDE]
9
10

}
11
12
13
14

C++ Programming Language


main.cpp sample.cpp

1 Text Editor
2
3 E.g: Atom, Sublime, Visual Studio Code
4 < A tool that is designed to edit text, designed to
5 work with whatever language or framework you
6 choose. Simpler and lightweight than IDEs. >
7
8 IDE (Integrated Development
9 Environment)
10
11 E.g: XCode, Eclipse, Visual Studio, CodeBlocks
12 < a set of tools that all work together: text editor,
13 compiler, build or make integration, debugging. IDEs are
tied specifically to a language or framework or tightly
14 collected set of languages or frameworks>

C++ Programming Language


main.cpp sample.cpp

1 Mobile App C++ Compilers


2
https://play.google.com/store/apps/details?id=com.k
3 vassyu.coding2.cpp
4 https://play.google.com/store/apps/details?id=ru.ii
5 ec.cxxdroid
6
https://apps.apple.com/ph/app/c-shell-c-code-
7
compiler/id6444545478
8 https://apps.apple.com/ph/app/c-c-programming-
9 compiler/id1160868782
10
11 Web App C++ Compilers
12 https://www.programiz.com/cpp-programming/online-
13 compiler/
https://onecompiler.com/cpp
14

C++ Programming Language


main.cpp sample.cpp

1 Create a C++ File on Codeblocks


2
3
4 2.
1.
5
6
7
8
9
10
11
12
13
14

C++ Programming Language


main.cpp sample.cpp

1 Create a C++ File on Codeblocks


2
3 3.
4
4. 5. Select file path to
5
save your file and set
6 the filename.
7
8
9
10
11
12
13
14

C++ Programming Language


main.cpp sample.cpp

1 Build and Run on Codeblocks


2
3 6.
4
5
6
7
8
7.
9
10
11
12
13
14

C++ Programming Language


main.cpp sample.cpp

1 Build and Run on Codeblocks


2
3 8. Abort or close exe file
to edit code and rebuild. Run, Build and Run
4
other otoptions and
5 shortcuts.
6
7
8
9
10
11
12
13
14

C++ Programming Language


main.cpp sample.cpp

1 Debugging on Codeblocks
2
Check the logs & others tab to debug error encountered in red.
3
4
5
6
7
8
9
Make sure Logs are
10 enabled/checked to view
11 the logs.
12
13
14

C++ Programming Language


main.cpp sample.cpp

10 {
1
2
3
4

[Codeblocks
5
6
7
8
9
10
Installation]
}
11
12
13
14

C++ Programming Language


main.cpp sample.cpp

1 Download Links: {
2
https://sourceforge.net/projects/codeblocks/
3 files/Binaries/20.03/Windows/codeblocks-
4 CodeBlocks 20.03mingw-setup.exe/download
5
6 Visual https://visualstudio.microsoft.com/
7 Studio vs/community/
8 CodeBlocks
9 Visual Studio
10
11
12
13
14 }
C++ Programming Language
main.cpp sample.cpp

1 Codeblocks Installation {
2 1. Download from provided link or from
3 https://www.codeblocks.org/downloads/binaries/
4 Select codeblocks-20.03mingw-setup.exe
5 2. Run the installer, just press Next after reading
each screen.
6
7 3. 4.
8
9
10
11
12
13
14 }
C++ Programming Language
main.cpp sample.cpp

1 5. 6.
2
3
4
5
6
7
8
9
7. 8. Select the detected
10
compiler and proceed.
11
12 Finish
13
14

C++ Programming Language


main.cpp sample.cpp

1 Thanks; {
2
3
‘Do you have any questions?’
4
5
[email protected]
6
7
8
9
CREDITS: This presentation template was
10 created by Slidesgo, including icons by
Slidesgo

11 Flaticon, and infographics & images by


Flaticon

Freepik
Freepik

12
< Please keep this slide for attribution >
13
14 }
C++ Programming Language

You might also like