0% found this document useful (0 votes)
14 views19 pages

Introduction To Programming

This document provides an introduction to programming, explaining that a computer program is a sequence of instructions that directs a computer to perform tasks. It outlines the importance of programming languages, algorithms, and the distinction between human and computer thinking. Additionally, it covers the process of problem-solving in programming and the roles of compilers and interpreters in translating code into machine language.

Uploaded by

elmky.saif
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)
14 views19 pages

Introduction To Programming

This document provides an introduction to programming, explaining that a computer program is a sequence of instructions that directs a computer to perform tasks. It outlines the importance of programming languages, algorithms, and the distinction between human and computer thinking. Additionally, it covers the process of problem-solving in programming and the roles of compilers and interpreters in translating code into machine language.

Uploaded by

elmky.saif
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

INTRODUCTION TO

PROGRAMMING
INTRODUCTION
INTRODUCTION

• A computer is a machine. Like other machines, such as an automobile,


it must be turned on and then driven, or controlled, to do the task it
was meant to do.
• In an automobile, for example, control is provided by the driver, who
sits inside and directs the car. In a computer, the driver is a set of
instructions called a program.
WHAT IS A PROGRAM?

• A computer program is a sequence of instructions that is used to


operate a computer to produce a specific result.
• Programming is the process of writing these instructions in a
language that the computer can respond to and that other
programmers can understand.
WHAT IS A PROGRAMMING LANGUAGE?

• A programming language is a formal language comprising a set of


strings that are used in computer programming to implement
algorithms.
• We can say that a programming language is a method of
communication between the programmer and the computer, through
which the programmer can give commands to the computer to
implement them and thus achieve a specific task.
• Example: Python, Java, C, C++, JavaScript.
INTRODUCTION

• On a fundamental level, all computer programs do the same thing.

• They direct a computer to accept data (input), to manipulate the data


(process), and to produce reports (output).
INTRODUCTION

• This implies that all computer programming languages must provide


essentially the same capabilities for performing these operations.
• If all programming languages provide essentially the same features, why
are there so many of them?
• Different programming languages are used for different purposes, like
JavaScript is good for web development, Python is good for AI, and
C/C++ is good for programming microcontrollers.
HUMAN VS COMPUTER THINKING

• Humans:
• Can infer
• Can assume
• Computers:
• Need exact instructions
• No assumptions
• No intelligence without programming
• Computers do exactly what you tell them. Not what you mean.
ALGORITHMS

• Before a program is written, the programmer must have a clear


understanding of what the desired result is and how the proposed
program is to produce it.
• In computer science, a computational procedure is called an
algorithm. More specifically, an algorithm is defined as a step-by-
step sequence of instructions that describes how a computation is to
be performed.
ALGORITHMS

• When English-like phrases are used to describe the algorithm (the


processing steps), as in this example, the description is called
pseudocode.
• When mathematical equations are used, the description is called a
formula.
• When pictures that employ specifically defined shapes are used, the
description is referred to as a flowchart.
ALGORITHMS

• Acceptable pseudocode for describing the steps needed to compute


the average of three numbers is:
1. Input the three numbers into the computer.
2. Calculate the average by adding the numbers and dividing the sum by three.
3. Display the average.
ALGORITHMS

• Only after an algorithm has been selected and the programmer


understands the steps required can the algorithm be written using
computer-language statements. When computer-language statements
are used to describe the algorithm, the description is called a
computer program.
ALGORITHMS
ALGORITHMS

• All programming falls into three basic procedures: sequence, selection,


and repetition.
• Sequence is the correct order of steps for solving a problem.
• Selection is the ability of the computer to make a decision and act on
it.
• Repetition is the ability of the computer to repeat a set of
instructions.
PROGRAM TRANSLATION

• Once a program is written in a high-level language it still cannot be


executed on a computer without further translation. This is because the
internal language of all computers consists of a series of 1s and 0s,
called the computer's machine language.
• To generate a machine-language program that can be executed by the
computer requires that the C++ program, which is referred to as a
source program, be translated into the computer's machine language.
COMPILER VS INTERPRETER

• There are two main ways this translation happens.


• A compiler translates the entire program at once into machine
language before execution.
Source Code → Compiler → Executable File → Run
• An interpreter translates and executes the program line by line.
Source Code → Interpreter → Executes line by line
COMPILER VS INTERPRETER
CONCLUSION
PROBLEM-SOLVING STEPS

• Problem-Solving Method
• Understand the problem
• Identify input and output
• Design the algorithm
• Test the algorithm (dry run)
• Translate into code
• Test and debug
REMEMBER

• Programming is NOT:
• Memorizing syntax
• Typing fast
• Being a math genius

• Programming IS:
• Logical thinking
• Problem solving
• Breaking big problems into small ones

You might also like