Docsity

Introduction to c++ language, Study notes of Programming Languages

Toggle sidebar
bg1
C++
C++ is a general-purpose programming language that was developed as an extension of the C programming language.
It was created by Bjarne Stroustrup, a Danish computer scientist, in the early 1980s at Bell Labs (AT&T). The
development of C++ began in 1979 when Stroustrup started working on "C with Classes," which later evolved into C+
+.
Introduction to C++:
C++ is often referred to as a "middle-level" programming language because it combines both low-level features
(similar to C) and high-level abstractions. It supports procedural, object-oriented, and generic programming
paradigms, making it a versatile language suitable for various applications. C++ is known for its efficiency,
performance, and ability to directly manipulate hardware, which makes it popular in systems programming, game
development, embedded systems, and more.
Key Features of C++:
1. **Object-Oriented Programming (OOP):** C++ supports the principles of OOP, including encapsulation,
inheritance, and polymorphism. This allows for the creation of modular and reusable code.
2. **Low-Level Manipulation:** Like C, C++ provides features for low-level memory manipulation, giving developers
control over system resources.
3. **Standard Template Library (STL):** C++ includes the STL, a powerful library of generic algorithms and data
structures, making it easier for developers to write efficient and maintainable code.
4. **Portability:** C++ programs can be written to be highly portable across different platforms, allowing developers
to write code that can run on various operating systems with minimal modifications.
5. **Performance:** C++ is known for its efficiency and performance, making it suitable for applications where speed
is crucial, such as game development and system programming.
History:
- **1979:** Bjarne Stroustrup starts working on "C with Classes."
- **1983:** The language is officially named C++ (pronounced "C plus plus"). This version includes classes, derived
classes, and basic inheritance.
- **1985:** The first edition of "The C++ Programming Language," written by Stroustrup, is published, providing a
comprehensive reference for the language.
- **1989:** C++ 2.0 is released, introducing multiple inheritance, abstract classes, static member functions, and const
member functions.
- **1998:** C++98, the first standardized version of C++, is released, formalizing the language's features and syntax.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Introduction to c++ language and more Study notes Programming Languages in PDF only on Docsity!

C++

C++ is a general-purpose programming language that was developed as an extension of the C programming language. It was created by Bjarne Stroustrup, a Danish computer scientist, in the early 1980s at Bell Labs (AT&T). The development of C++ began in 1979 when Stroustrup started working on "C with Classes," which later evolved into C+ +.

Introduction to C++:

C++ is often referred to as a "middle-level" programming language because it combines both low-level features (similar to C) and high-level abstractions. It supports procedural, object-oriented, and generic programming paradigms, making it a versatile language suitable for various applications. C++ is known for its efficiency, performance, and ability to directly manipulate hardware, which makes it popular in systems programming, game development, embedded systems, and more.

Key Features of C++:

  1. Object-Oriented Programming (OOP): C++ supports the principles of OOP, including encapsulation, inheritance, and polymorphism. This allows for the creation of modular and reusable code.
  2. Low-Level Manipulation: Like C, C++ provides features for low-level memory manipulation, giving developers control over system resources.
  3. Standard Template Library (STL): C++ includes the STL, a powerful library of generic algorithms and data structures, making it easier for developers to write efficient and maintainable code.
  4. Portability: C++ programs can be written to be highly portable across different platforms, allowing developers to write code that can run on various operating systems with minimal modifications.
  5. Performance: C++ is known for its efficiency and performance, making it suitable for applications where speed is crucial, such as game development and system programming.

History:

  • 1979: Bjarne Stroustrup starts working on "C with Classes."
    • 1983: The language is officially named C++ (pronounced "C plus plus"). This version includes classes, derived classes, and basic inheritance.
  • 1985: The first edition of "The C++ Programming Language," written by Stroustrup, is published, providing a comprehensive reference for the language.
  • 1989: C++ 2.0 is released, introducing multiple inheritance, abstract classes, static member functions, and const member functions.
  • 1998: C++98, the first standardized version of C++, is released, formalizing the language's features and syntax.
  • 2011: C++11 is released, introducing significant improvements and new features, including auto keyword, lambda expressions, and smart pointers.
  • 2014: C++14 is released, adding enhancements and bug fixes to C++11.
  • 2017: C++17 is released, featuring new features like parallel algorithms, filesystem library, and more.
  • 2020: C++20 is released, introducing concepts, ranges, and other improvements to the language. C++ continues to evolve, with regular updates and new standards to meet the changing needs of the software development community. It remains a popular and influential programming language in various domains. Hardware and Software Hardware Hardware refers to the physical components of a computer. These components are tangible. Hardware is further divided into input devices, output devices, secondary storage devices and internal components. Input Devices Firstly, input devices are the components that send data to the computer. Some examples are as follows. Keyboard is a device that allows the user to enter input data. The layout of the keyboard is similar to a typewriter with additional keys. Another input device is a mouse. It consists of left, right mouse buttons, and a wheel. It cannot be used to enter text into the computer. According to the mouse movement, it is possible to control the position of the cursor on the screen. Joysticks, Light Pen,

Internal Components Most importantly, the internal components are the elements that directly connects with the main functionalities of the computer. CPU, RAM, ROM, and motherboard are few examples. CPU is the main execution unit of the computer. It divides further into two components: Arithmetic and Logic Unit (ALU) and the Control Unit (CU). The ALU performs the mathematical calculations and the logical operations. The Control Unit (CU) carries the control signals to operate other components. RAM which stands for Random Access Memory that stores data, programs and program results for the CPU to perform tasks. It is possible to perform read and write operations in RAM. The amount of RAM is a considerable factor to determine the performance of the computer. It requires more time for the CPU to access secondary storage such as hard disk for all operations. Therefore, the RAM is used as the primary storage. It is a volatile memory. Therefore, it holds data temporary. In other words, powering off the device will erase the data in the RAM. ROM stands for Read Only Memory. It is only possible to read from the ROM. It is a nonvolatile memory, so the data is permanent. It consists of the instructions required to start a computer. Moreover, a motherboard is a single platform. It connects CPU, memory, hard drives and other ports through cables. Those are main hardware components found in a computer. What is Software Software is a collection of procedures, instructions, documentation that tells a computer exactly what to do or allows users to interact with a computer. Sometimes it is abbreviated as S/W and SW, which is most important for a computer or other similar devices. Most of the computers may be useless without software. For example, if a software program, MS-Word is not installed into your computer, you cannot make any document that can be completed through MS-Word. Also, you cannot surf the Internet or visit any website if your system has no Internet browser software. Additionally, the browser could not run on the computer without an operating system. The Google Chrome, Photoshop, MS Word, Excel, MySQL and more are examples of software. The picture is shown below, is an example of software, which is a picture of Google Chrome, which is an Internet software program.

Figure 2: Software System Software System software allows operating, controlling and extending the processing capability of a computer. This software is necessary to run hardware and application software. They are the interface between the hardware and the end users. Usually, computer manufacturers develop system software. The common programming languages to develop system software are C, C++, and Assembly language. Some examples for system software are operating system, compilers, assemblers, interpreters and device drivers. An operating system performs task management, memory management, file handling and hardware management and many more. The compilers and interpreters convert a high-level program into machine understandable machine code. An assembler converts the assembly language program to machine code. The device drivers control and monitor the functionalities of specific devices such as printers.

o Entertainment Software: Video games, multimedia players, and streaming programs are examples of entertainment software. These programs allow users to participate in engaging, entertaining, and recreational activities. o Communication Software: Email clients, instant messaging programs, video conferencing tools, and web browsers are all examples of communication software. These programs allow users to connect, work together, and access internet resources.

  1. Instruction Set Architecture (ISA):
    • ISA defines the set of instructions that a CPU can execute.
    • It includes operations like arithmetic, logic, data movement, and control transfer instructions.
  2. Pipelines and Parallelism:
    • Many modern CPUs use pipelining to execute multiple instructions simultaneously by breaking down the instruction execution process into stages.
    • Parallel processing techniques, such as multiple cores or threads, can further enhance the performance of a computer system.
  3. Cache Memory:
    • Cache memory is a small, high-speed memory located within or near the CPU.
    • It stores frequently accessed data and instructions to speed up the execution of programs.
  4. Memory Hierarchy:
    • Computer systems often have multiple levels of memory with varying speeds and capacities arranged in a hierarchy.
    • The memory hierarchy includes registers, cache, RAM, and secondary storage.
  5. Input/Output Operations:
    • The CPU communicates with I/O devices through specific instructions and addresses, allowing data transfer between the computer and external devices.
  6. Control Unit and Microprogramming:
    • The control unit manages the execution of instructions by generating control signals that coordinate the activities of other components.
  • Microprogramming involves using a set of microinstructions to control the internal operations of the CPU. Understanding computer organization is crucial for computer architects, hardware designers, and system programmers to optimize the performance, efficiency, and reliability of computer systems. It involves balancing trade-offs between factors such as speed, cost, and power consumption. Bytes What is a byte?

In most computer systems, a byte is a unit of data that is eight binary digits long. A byte is the

unit most computers use to represent a character such as a letter, number or typographic symbol.

Each byte can hold a string of bits that need to be used in a larger unit for application purposes.

As an example, a stream of bits can constitute a visual image for a program that displays images.

Another example is a string of bits that constitute the machine code of a computer program.

Byte is abbreviated with an uppercase B.

Bytes in computer processing and programming

In some computer systems, four bytes constitute a word, a unit that a computer processor can

handle efficiently as it reads and processes each instruction. Depending on the capabilities, some

computer processors can handle two-byte or single-byte instructions. Language scripts can

sometimes require two bytes to represent a character. These are called double-byte character sets.

How many bits in a byte?

A bit is represented by a lowercase b. While a byte can hold a letter or symbol, a bit is the

smallest unit of storage, storing just one binary digit. The standard number of bits in a byte is

eight, but that number can vary from system to system, depending on the hardware.

Fred Brooks, an early hardware architect at IBM, project manager for IBM's OS/360 operating

system and author of The Mythical Man-Month , credits Werner Buchholz for originating the

term byte in 1956 when working on IBM's Stretch computer. Initially, there could be one to six

bits in a byte because the equipment at the time used 6-bit pieces of information. The change to

eight bits in a byte occurred later in the same year with OS/360 circulating the new standard.

A gigabyte (GB) is equal to 1,073,741,824 bytes. As a frame of reference, a computer may have

up to 4 GB of RAM; a single layer DVD can hold up to 4.7 GB of data; a hard drive could be

used to hold 750 GB; or a video game could have 30-60 GB of data.

A terabyte (TB) is 1,000,000,000,000 bytes, or 1,000 GB. External hard drives may commonly

be found at around 1-8 TB.

What is Character?  In computer words, It can be the representation of anything, let it be comma, punctuation, or next line, or any symbol which has a measurable size in bits. Its definition was first given by ASCII and represents any kind of symbol in the terminology. Even the word computer has characters. It is otherwise called char and can represent texts, numbers, or symbols used in the codes or languages.  Here, something to note is that all the characters should belong to any program or at least to the OS. This makes the character have an identity, and it will not throw any error when called in the language or any program. They are represented in different

ways, such as if they are texts or letters, they should be represented within single quotes, while if they are numbers, It will not use any quotes to represent the same.  It will have meaning, and meaningless letters or symbols are not part of the character. Each character represents the flow of a program and is important to ensure efficient working of the program or coding in the system. Even space is a character, and if graphics-based applications are considered, all the punctuations and symbols on the screen are characters.  It is the visual representation of the information through any letter or number, or symbol passed in the program or the stored data to run successfully in the system. All the information is displayed on the system, and hence we can say that characters store and display the information of any program related to it. Importance of Character

  1. The entire implementation of characters of any type in a program is done with the help of character. With memory, anything can be stored in the character as it has ASCII values. This helps in storage of any type, and hence the special character’s storage finds away. In a program, if it is represented as char and two values are given in a single quote, it becomes invalid. Also, numbers are never given inside quotes as this also becomes invalid.
  2. Though most are in letters and numbers, there are instances where the presence of special characters alters the performance of the entire texts or numbers. This changes the meaning of the entire sequence, and hence the presence of specials is acknowledged in the coding programs. This is called the escape sequence and represents a different meaning to the entire context. Some language offers additional support to manipulate the code, and this also helps to use the code differently.
  3. Now coming to the most common coding language of today, python does not support any characters, and it represents the group in the system. This is called strings and have various advantages in using them. A special representation of char is not needed

is important to denote the end of a program or a string in the computer program. Other non-printable keys are the enter key and tab key. We can say that letters, symbols, emojis, and numbers are types as each represents the representation, and one cannot be replaced for another. Symbols cannot be avoided in a program, and each symbol is represented by keys so that each is recognizable in its own ways. Smileys or emojis come under the Unicode standard and have a specific size for each smiley. Conclusion They are important to any program or process in the computer, and understanding it becomes the basis for understanding any program or the computer hardware. All the processes are represented with the help of characters and recognized to modify the codes in the program