You are on page 1of 16

IFTH1006

Assignment 3
What is C++?

• C++ is a high level language.


• A high level language refers to a language used for programming that is closer
to a language used by humans rather than a machine.
• This makes the language easier to use than lower level languages.
• C++ has certain features as a high level language.
C++ Features

• The features of C++ include:


1. C++ is simple. The method by which a problem can be broken down in C++
is simple due to its other features such as the data types and the library.
2. C++ can used in a variety of machine without any major changes.
3. C++ is a mid level language. It can be used for both high and low levels of
programming.
C++ Features

4. C++ programs can be divided into parts called functions.


5. The C++ library contains many functions. This library is inbuilt.
6. C++ has dynamic memory allocation.
7. C++ has a quick compilation and execution speed.
8. C++ has pointers which are used to directly interact with the memory or
storage locations.
9. C++ can easily be extended with new features.
C++ Features

11. C++ is an object oriented programming (OOP) language. OOP means that
programming is done through objects. These objects encapsulate data and
functions that operate on the data or other functions.
12. C++ programs must be compiled before being executed.
C++ Structures and Constructs

• C++ also has structures and constructs. These control the language. These
include simple structures such as sequential structures, repetition structures and
selection structures.
C++ Structures and Constructs

• Sequential structures allow the program to flow in the order instructions are
placed. This is the default for C++.
• Repetition structures include for, do…while and while loops which repeat a
part of the program.
• Selection structures include if…then, if…then…else, if…then…elseif and
switch which allows the program to execute a different part of the program
depending on a condition.
Functions

• C++ structure and constructs also includes functions.


• A function is a part of the program that executes when called.
• Functions must be declared and defined before being called.
• A function is called when the program executes the statement that can call it.
• All C++ programs contain at least one function.
• Functions also control the flow of the program because when they are called
the program executes the instructions inside the function.
Data Types and Structures

• Data types are also part of C++.


• Data type refers to a specific set of values.
• What data or values that can be entered into an identifier (variable) is
determined by its data type. The data type of a identifier also determines the
amount of memory allocated to it
• Anything outside this set of values will either not be accepted or changed to the
data type.
• Functions can only accept and return certain types of data.
Data Types and Structures

• The data type of an identifier is determined by the programmer.


• The data types that can be given to identifiers include int (integers), float
(decimals), double (decimals), char (a single character), string (multiple
characters), bool (true or false) and void (no value).
Data Types and Structures

• Data Structures are the way data is stored such that the data can be operated on
smoothly.
• Data structures include arrays, linked lists, stacks, queues, hash tables, trees,
heaps and graphs.
Data Types and Structures

• Arrays store data of the same type in locations next to each other. They are of a
set size and the locations are numbered starting from 0. Data is accessed by
going to the number (index) that contains the necessary data.
• Linked lists store data in nodes, which are sorted linearly. Each node is linked
to the next by a pointer. Data accessed by going from the head (pointer to the
first data storage location) to the node that contains the necessary data. Each
node is only connected to one other node.
Data Types and Structures

• Stack store data in a last in first out manner meaning that the first piece of data
that can be accessed first is the last piece of data stored.
• Queues store in a first in first out manner meaning that the first piece of data
that can be accessed first is the first piece of data stored.
Data Types and Structures

• Hash tables store data and associate each piece with a key. Data is accessed by
looking for and accessing the key of that data.
• Trees store data in a linked hierarchy. This means that there are levels on which
data is stored and they can be accessed by going from one piece of data to the
next due to being linked. Like linked lists, data is stored in nodes but a node on
a higher level can be connected to multiple lower level nodes.
Data Types and Structures

• Heaps are a specific type of tree where the data in each level of the hierarchy is
determined by comparing the data in each level and arranging them in a
specific order based of that comparison.
• Graphs store data in nodes or vertices. These vertices can be connected to each
other by edges. Unlike trees and linked list, not all nodes have to be connected,
nodes do not have to be sorted or be in a specific order like a hierarchy or on a
line.
References

• Javatpoint. (n.d.). C++ Features. Javatpoint. https://www.javatpoint.com/cpp-features


• Zak, D. (2015). An introduction to programming with C++ Eighth edition. Cengage Learning.
• Mallawaarachchi, V. (2020, Feb. 28). 8 Common Data Structures every Programmer must
know. Towards Data Science.
https://towardsdatascience.com/8-common-data-structures-every-programmer-must-know-171
acf6a1a42#:~:text=Data%20Structures%20are%20a%20specialized,Computer%20Science%20
and%20Software%20Engineering

You might also like