0% found this document useful (0 votes)
2 views41 pages

PDFen

The document provides an introduction to C++ programming, covering its history, basic structure, and key programming paradigms. It also discusses data types, variables, expressions, and the importance of syntax and semantics in programming. Additionally, it offers a preview of other programming languages and emphasizes the significance of community support for learning.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views41 pages

PDFen

The document provides an introduction to C++ programming, covering its history, basic structure, and key programming paradigms. It also discusses data types, variables, expressions, and the importance of syntax and semantics in programming. Additionally, it offers a preview of other programming languages and emphasizes the significance of community support for learning.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 41

Introduction to C++

Programming and Preview


of other Programming
Languages
Prepared by: Eric Alipan
What is a Programming Language?
• A set of instructions used to
communicate with a cCo+m+ pOuvetervr.iew

• Translates human ideas into a format the


computer understands.
C++ Overview
• General-purpose, high-level programming
language.
• Developed by Bjarne Stroustrup in 1979 at
Bell Labs.
• Combines features of both high-level and low-
level
languages.
Programming Paradigms:
Types & Differences
Imperative Paradigm
• Focuses on describing a sequence of steps to
achieve a goal.

Examples: C, C++, Java.


Declarative Paradigm
• Focuses on describing what the program
should accomplish rather than how.

Examples: SQL, Prolog.


Object-Oriented Programming (OOP)
• Organizes data and behavior into
objects.

Examples: C++, Java, Python.


Functional Programming
• Focuses on mathematical functions and avoids
mutable data.

Examples: Haskell, Scala, F#.


C++ Programming Language Type and Level

Type Level Key Features


Multi-paradigm High-level Object-Oriented:
(supports language (but also Supports classes,
inheritance,
procedural, object- allows low- level
polymorphism.
oriented, and operations like direct Generic Programming:
generic memory access). Uses templates for type
programming). safety and flexibility.
Historical Perspective of C++
• 1979: Developed by Bjarne Stroustrup at Bell
Labs as “C with Classes.”

•1983: Renamed to C++ and


standardized.

•Key Milestones:
1985: First commercial version.
1990s: Introduction of Standard Template Library
(STL).
2011: C++11 standard introduced, with major
updates.
Basic C++ Program Structure

General Structure:

•Preprocessor Directives: Include necessary


libraries.
•Main Function: Entry point of the program.
•Statements/Expressions: The actual
operations
performed.
Basic C++ Program Structure

Exampl
e:
#include Preprocessor
<iostream> // directive
int main() { // Main
function
std::cout << “Hello, World!” << Outp
statement
std::endl; // ut
return 0; // Return
statement
}
Creating a Simple “Hello World” Program

01 Include the iostream


library to use
input/output functions.
02 Define the main
function where
execution begins.

03 Output the “Hello


World” message
04 Return 0 to
indicate successful
using std::cout. execution.
Creating a Simple “Hello World” Program

Example:

#include

<iostream> int

main() {
std::cout << “Hello World!” <<
std::endl; return 0;
}
Preview of Other Programming
Languages
Preview of Other Programming Languages

• Java: Object-oriented, widely used in enterprise applications.


• Python: High-level, interpreted language known for its readability and
simplicity.
• JavaScript: Essential for web development, both client-side and server-side.
• Rust: Focuses on memory safety and concurrency, a systems programming
language.
• Go: Developed by Google, known for its simplicity and concurrency support.
Thanks!
Does anyone have any
questions?
[email protected]
+91 620 421 838
yourwebsite.com

CREDITS: This presentation template was created by Slidesgo,


including icons by Flaticon, and infographics & images by
Freepik

Please keep this slide for attribution


Data Types, Variables,
Expressions, and
Assignment

Prepared by: Eric Alipan


What are Data Types?
• Data types define the kind of data that a
variable can hold.
Types of Data Types
• Primitive: Built-in types like integers,
floats, and characters.
•Derived: Arrays, pointers, and references.
•User-Defined: Structures, classes, and
enumerations.
Common Data Types in C++
Common Data Types in C++
Variables
• A variable is a named memory location that
stores a value.
Variables
•Rules for Naming Variables:

Must start with a letter or underscore.


Can contain letters, digits, and
underscores.
Case-sensitive (e.g., MyVar and myvar are
different).
Expressions
• An expression is a combination of variables,
constants, and operators that produce a value.
Expressions
• Types of
Expressions:

Arithmetic: x + y,
a * b Relational: x
> y, a == b
Logical: x & & y, a |
b
Assignment
• The process of assigning a value to a
variable.
•Syntax:
variable = value;
•Compound Assignment Operators:
+=, -=, *=, /=, %=
Combining All Concepts
Code Example:

#include
<iostream> using
namespace std;
int main() {
int num1 = 10; Variable declaration and assignment
// Another variable
float num2
result = num1
20.5; + Expression
num2;
cout << //.“Result: “ << result <<
//
endl; // Output
return 0;
}
Syntax and Semantic

Prepared by: Eric Alipan


Syntax consists of the formal rules that specify how statements in a
programming language should be structured, ensuring code is written
in a recognizable format.

SY N TAX A ND SEM A NT IC S

U5DE9STAMDI56
STMT@AMD S£MA5TICS:
D£FIMITI0MS AMD
APPLC
I ATO
I NS
Exploring the Core Concepts
Essential for Effective Programming
SYNTAX OV E RVI E

DEu
W
riT
O
i MAMD9ULE3Or3vMTbiMC
Understanding the Essentials of
++
Syntax

Safinitian af5yntax Identifiers


Syntax is the set of rules governing Identifiers are names used for Keywords are reserved words in C++
the structure and arrangement of variables and functions, following with special meanings, such as 'int'
symbols, keywords, and operators in specific naming conventions to for integer declaration and 'return' to
a programming language, essential enhance readability and exit a function, which must not be
for writing valid code. maintainability of the code. used as identifiers.

5
Example of 6yntax in C++
Operators are symbols that perform The provided code snippet illustrates Adhering to syntax rules is crucial in
operations on variables and values, C++ syntax by showing variable programming to ensure code is
including arithmetic operators like '+', declarations and an arithmetic understood by the compiler, preventing
'-', '”', and '/' to conduct mathematical operation, adhering to the language's errors and enabling successful execution.
calculations. syntax rules.
EXPL0RM
I ¢ SEMANTC
IS
Understanding the Relationship Between Syntax and
Semantics
SVMT@VS. SEMANTC
IS
Understanding Key Differences in Programming
Concepts

definition
Syntax: Structure of
code Semantics:
Meaning of code

Syntax Errors: Compilation


errors
• Semantic Errors: Runtime
errors

• Syntax: Ensures valid code


Semantics: Ensures correct program
behavior
U DERSTA DI ¢ SVET@AED
SEMANTC
IS
A deep dive into the definitions, interrelations, and significance of syntax [tt
and semantics in programming and beyond. g
Present
er
HO¥USVMT@ M
I FLUfMCES
CODEREADAäILITÏ
Enhancing Code Clarity and Collaboration

Proper syntaz enhances Sÿntal IÏighlighting in l5f-6


code readability and Syntax errors, such as
Modern Integrated
maintainability.
Development Environments missing semicolons or
Clean, well-structured (IDEs) utilize syntax misplaced braces, can
code is essential for highlighting to visually cause significant delays in
readability, making it differentiate code elements, development by preventing
easier for developers to aiding programmers in code from compiling,
understand and modify quickly identifying necessitating thorough
each other's work. variables, functions, and syntax checks.
errors.
SE MANTIC ANALY

HO¥US£MAETC
SIS
I SAFFECTPRO¢RAM ä£HAVO
lR
Understanding the Role of Semantics in Code and Compiler
Functionality

Importance af Cède 3tudy: C++ Code Exemple 9untima Errors


Ensures that a program 3amantic 3amentic int main() ( int a = Semantic errors can
Àn8lÿBÏ8
behaves as intended, Demonstrates a 10; int b = 0; int c = cause unexpected
vital for effective Compilers conduct semantic error a / b; ) - This code is behavior at runtime,
debugging and semantic analysis to through division by syntactically correct illustrating the
optimization. ensure logical zero, highlighting the but leads to a runtime importance of
consistency, addressing difference between error. semantic checks.
issues like type checking syntactic and
and scope resolution. semantic correctness.
Overview of highlighting CommunigEgagsms
Available cplusplus.com t
R£S0URC(S FORLEARMM
I¢ Resources
There are numerous
As a leading platform in The forum at

STMT9 AMDS(MASTICS
the programming cpIuspIus.com fosters a
resources available for community, vibrant community where
programmers to cpIuspIus.com offers users can exchange
Exploring Tools and Community
enhance their extensive tutorials ideas, seek help, and
Engagement for C++ Programming understanding of covering crucial C++ stay informed about the
syntax and semantics, topics such as pointers, latest advancements in
including books, functions, and C+ + programming.
online courses, and templates, alongside
forums that provide user- contributed articles
valuable insights. that provide diverse
perspectives.
A powerful IDE that offers real-
time syntax checking,
debugging tools, and a
Several tools facilitate
comprehensive development
syntax and semantic error
environment.
00MM0NT00tSF0RS¥NlHA checks, ensuring code
quality and functionality.
SEMANT
ND C
ICH£CK
Enhancing Programming
Efficiency

helpsIntdemffying symax
er
duArIg coding, prpvlding @
user-
friendly eXperJence•
M
I P09TAMCE OF COMMUM
TIV SUPPORT
Engaging with the community in programming

Impartanra of community support


Engaging with the community is essential for mastering
programming concepts such as syntax and semantics,
providing a supportive environment for learning.

Participating in forums can yield valuable insights, foster


collaboration, and enhance understanding through shared
experiences and knowledge.

Mighlightingrplusplus.HamCommunity
The cpIuspIus.com community forum serves as an excellent
resource where programmers can ask questions, share
knowledge, and help one another tackle C++ programming
challenges.
PROGRAMMING ESSENTIALS

R£CAPOFTHEIMPOR
T
AMC£ OFSTMT@AMD S£MAMTC
ISM
I PRO¢RAMMM

Key Takeaways

Syntax refers to the Semantics deals with Both syntax and Utilizing resources like Engaging with the
rules that define the the meaning behind semantics are critical cpIuspIus.com programming
structure of code, the code. It is essential for writing correct and provides valuable community can
ensuring that it is for understanding what efficient programs. A insights and examples provide additional
written correctly to be the code is intended small syntax error can that can enhance support and
interpreted by the to accomplish during lead to runtime issues, understanding of both knowledge,
compiler. execution. while semantic errors syntax and semantics facilitating
can result in in C++. continuous learning
unintended behavior. and growth in your C+
+ programming
journey.
MASTER SVMT@ AMD SEMANTC
IS
Join us to exDlore the essential roles of Svntax and Semantics in lanauaae and technoloav. Enhance vour analvtical
and aDDlication skills

You might also like