FUNDAMENTALS OF ROGRAMMING
|Introduction to Programming|
MARK L. MASCARDO
College of Computing Studies (CCS)
• Definition:
What is Programming?
• Programming is the process of creating a set of instructions that a computer follows to
perform a specific task.
• These instructions are written in a programming language, which acts as a bridge
between human language and machine code.
• Real-Life Analogy:
• Imagine programming as writing a recipe. Just as a recipe provides step-by-step
instructions to make a dish, a program provides step-by-step instructions to the computer
to complete a task.
Why is Programming Important?
• Automation:
• Programming enables the automation of tasks, making them faster and reducing the
possibility of human error.
• Problem Solving:
• Programmers create software to solve real-world problems, from managing financial
transactions to controlling robotic systems.
• Innovation:
• Programming drives technological innovation, powering everything from smartphones to
advanced artificial intelligence systems.
The Role of a Programmer
• Understanding the Problem:
• Before writing any code, a programmer must thoroughly understand the problem that
needs to be solved.
• Designing the Solution:
• Programmers often design the solution using flowcharts, diagrams, or pseudocode before
writing the actual code.
• Writing Code:
• Code is written in a programming language that the computer can interpret and execute.
• Testing and Debugging:
• After writing code, programmers must test it to ensure it works correctly and debug any
errors that arise.
What is a Programming Language?
• Definition:
• A programming language is a formal language that comprises/consist of a set of
instructions that can be used to produce various kinds of output.
• Examples of Programming Languages:
• High-level languages: Python, Java, C++, JavaScript.
• Low-level languages: Assembly, machine code.
• Choosing a Language:
• The choice of programming language depends on the task. For example, Python is often
used for data analysis and web development, while C++ is preferred for system
programming.
Basic Concepts in Programming
• Algorithms:
• An algorithm is a step-by-step procedure to solve a problem.
Every program is based on an algorithm.
• Flowcharts:
• A flowchart is a graphical representation of an algorithm. It
helps visualize the flow of control in a program.
• Pseudocode:
• Pseudocode is an informal high-level description of the
operating principle of a program or algorithm. It uses plain
language to outline the logic before actual code is written.
Writing Your First Program
• Example: "Hello, World!"
• The "Hello, World!" program is traditionally the first program written by someone
learning a new programming language. It simply outputs the text "Hello, World!" on the
screen.
• print("Hello, World!")
• Explanation:
• In this example, print is a function that displays the specified message ("Hello, World!")
on the screen.
Compiling and Running a Program
• Source Code:
• The code that a programmer writes is called source code. This source code needs to be
translated into machine code that the computer can execute.
• Compilation/Interpretation:
• Depending on the programming language, this translation is done either by a compiler
(for languages like C++ or Java) or an interpreter (for languages like Python).
• Execution:
• Once translated, the computer executes the machine code, performing the tasks as
specified by the original program.
Overview of Programming Paradigms
• Procedural Programming:
• A paradigm based on the concept of procedure calls, where programs are structured as
sequences of statements or commands.
• Object-Oriented Programming (OOP):
• A paradigm based on the concept of "objects," which can contain data and code that
manipulates that data.
• Functional Programming:
• A paradigm that treats computation as the evaluation of mathematical functions and
avoids changing-state and mutable data.
Getting Started with Programming
• Choosing an IDE:
• An Integrated Development Environment (IDE) is a software application that provides
comprehensive facilities to programmers for software development. Examples include
PyCharm, Visual Studio Code, and Eclipse.
• First Coding Exercise:
• As a practice exercise, write a simple program that takes user input and performs a basic
operation, such as adding two numbers together.