01-PROGRAMMING introA of the class name. Pptx

simukondasankananji8 17 views 20 slides Jul 19, 2024
Slide 1
Slide 1 of 20
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20

About This Presentation

The weekend of


Slide Content

Programming (C++) Mr Pelekamoyo (MICT)

Basic Computer Programming Computer Programming is a set of instructions, that helps the developer to perform certain tasks that return the desired output for the valid inputs. A computer is a machine that processes data that is provided by the user through devices such as keyboards, mouse, scanners, digital cameras, joysticks, and microphones. These devices are called Input Devices and the information provided is called input.

How Do Computers Work? The computer requires storage to store this information and the storage is called Memory, which is of Two Types. Primary Memory or RAM (Random Access Memory): RAM can be accessed or modified quickly in any order or randomly. The information that is stored in RAM is lost when the computer is turned off. Secondary Memory or ROM (Read-Only Memory): Information (data) stored in ROM is read-only is stored permanently. The ROM stored instruction is required to start a computer.

Algorithm A developer can analyze the problem and come up with simple steps to achieve a solution to this problem, for which he/she uses a programming algorithm . In the development environment, the products, software, and solutions can be designed as scenarios, use cases, and data flow diagrams .

Basic Programming Concepts Algorithm: It is a set of steps or instruction or statements to be followed to accomplish specific tasks. For Example, a recipe to cook a dessert. The algorithm describes the steps to be followed for completing a specific task, but it does not say how to achieve any of the steps. Source code: Source code is the actual text that is used to construct the program using the language of choice, like the text below: int main( { //Steps to be performed }

Compiler: Compiler is a software program that helps in converting the source code into binary code or byte code, also called machine language, that is easy for a computer to understand, and can be further executed using an interpreter to run the program. Data Type: Data used in the applications can be of a different type, it can be a whole number (integer), floating-point (decimal point numbers), characters or objects. For Example, double currency = 45.86, where double is a data type used for storing numbers with decimal points. Variable: Variable is a space holder for the value stored in the memory and this value can be used in the application. For Example, int age = 25, where age is a variable.

Conditionals: A set of code which execute only if a certain condition is true. In case of a false condition, the program should exit and should not continue the code further. Array: Array is the variable that stores elements of a similar data type. Loop: Loop is used to execute the series of code until the condition is true. For Example, in C languages and Java language, loops can be used as for loop, do-while, while loop or enhanced for loop. example: for (int i=0; i<=10; i++) { System.out.println(i); }

Function: Functions or methods are used to accomplish a task in programming, a function can take parameters and process them to get the desired output. Functions are used to reuse them whenever required at any place repeatedly. Class: Class is like a template that contains state and behavior, which corresponding to programming is field and method. In Object-Oriented languages like Java, everything revolves around Class and Object.

Computer Programming Languages a programming language is a special language or a set of instructions to communicate with computers. Each programming language has a set of rules (like English has grammar) to follow and it is used to implement the algorithm to produce the desired output.

Programming languages A program is a set of instructions that the computer can understand. Programs are written in programming languages, and there are several different languages that can be used. The choice of programming language depends upon who is writing the program and what they want it to do. There are two levels of programming language. These are: Low-level languages, including machine language, machine code and assembly languages High-level languages Procedural Language, Non-procedural Language, Object-oriented Language

Levels of Programming Languages

Low-level Language Hardware dependent Difficult to understand Low-level Language can be further divided into two categories, Machine Language: Machine dependent, difficult to modify or program, For Example, every CPU has its machine language. The code written in machine language is the instructions that the processors use. Assembly Language: Each computer’s microprocessor that is responsible for arithmetic, logical and control activities needs instructions for accomplishing such tasks and these instructions are in assembly language. The use of assembly language is in device drivers, low-level embedded systems, and real-time systems.

MACHINE LANGUAGES They are the native languages of the computer closest to the hardware. Each unique computer has a unique machine language. A machine language program is made up of a series of binary patterns (e.g., 01011100) which represent simple operations that can be accomplished by the computer (e.g., add two operands, move data to a memory location). Machine language programs are executable, meaning that they can be run directly. Programming in machine language requires memorization of the binary codes and can be difficult for the human programmer.

ASSEMBLY LANGUAGES Second-generation languages provide one abstraction level on top of the machine code. In the early days of coding on computers like the TX-0 and PDP-1, the first thing MIT hackers did was write assemblers. They represent an effort to make programming easier for the human. The machine language instructions are replaced with simple mnemonic abbreviations (e.g., ADD, MOV). Thus assembly languages are unique to a specific computer (machine). Prior to execution, an assembly language program requires translation to machine language. This translation is accomplished by a computer program known as an Assembler. Assemblers are written for each unique machine language.

High-level Language Independent of hardware Their codes are very simple and developers can read, write and debug as they are similar to English like statements. High-level Language can be further divided into three categories. Procedural Language : Code in the procedural language is a sequential step by step procedure, that gives information like what to do and how to do. Languages such as Basic, C, and Pascal, etc Non-procedural Language : Code in non-procedural language specify what to do, but does not specify how to do. Like SQL, Prolog, LISP, etc Object-oriented Language : Use of objects in the programming language, where the code is used to manipulate the data. LikeC ++, Java, Ruby, and Python, etc

High-level languages High-level languages are easier to use because they are designed with the programmer in mind. They are not machine-dependent and allow a program to be written so that it can be used on many different computers. Many of the instructions in high-level languages are in American English. Examples of high-level languages are: HTML – Hyper Text Mark up Language is used to develop websites. Java: Desktop GUI application (AWT or Swing api ), Applets, online shopping sites, internet banking, jar files for secured file handling, enterprise applications, mobile applications, gaming software. C: Operating Systems, Embedded systems, Database management systems, Compiler, gaming and animation.

Python: Machine learning, Artificial Intelligence, Data analysis, face detection and image recognition Software. C++: Banking and trading enterprise software, virtual machines and compilers. Visual Basic .NET : Windows services, controls, control libraries, Web applications, Web services. C#: Desktop applications like a file explorer, Microsoft office applications like Word, Excel , Web browsers, Adobe Photoshop. JavaScript: Client side and server side validations, DOM handling, developing web elements using jQuery (JS library). PHP: Static and dynamic websites and applications, Server side scripting. SQL: Querying database, CRUD operations in database programming, creating a stored procedure, triggers, database management.

Translation languages Translation languages convert program commands into machine code. There are two main types of translation languages. These are: Interpreters Compilers Interpreters convert each instruction into machine code, and then carry them out. Compilers convert the whole program into machine code before carrying the instructions out.

Relationship between assemblers, compilers, and interpreters

INTERPRETER COMPILER Translates program one statement at a time. Scans the entire program and translates it as a whole into machine code. It takes less amount of time to analyze the source code but the overall execution time is slower. It takes large amount of time to analyze the source code but the overall execution time is comparatively faster. No intermediate object code is generated, hence are memory efficient. Generates intermediate object code which further requires linking, hence requires more memory. Continues translating the program until the first error is met, in which case it stops. Hence debugging is easy. It generates the error message only after scanning the whole program. Hence debugging is comparatively hard. Programming language like Python, Ruby use interpreters. Programming language like C, C++ use compilers. Next lesson, will cover the Program structure , Input / Output Operations, Variables and Data types, C++ Operators, and C++ Conditionals
Tags