(PRF193) - 1.introduction & Setup
(PRF193) - 1.introduction & Setup
FUNDAMENTALS (WITH
C/C++)
PRF193
INTRODUCTION & SETUP
COURSE INTRODUCTION
GETTING/INSTALLING PROGRAMMING TOOL
BASIC STRUCTURE OF C/C++ PROGRAMS
OBJECTIVES
• This chapter provides fundamental concepts in computer
programming. After completing this chapter, you should be
PRF193
able to:
• Understand Course Introduction
• Gain a clear overview of the course objectives and structure.
• Set Up Your Development Environment
• Download and install necessary programming tools and IDEs.
• Get familiar with using Code::Blocks or other C/C++ development
environments.
• Understand the Basic Structure of C/C++ Programs
• Learn the foundational structure, syntax, and components of C/C+
+ programs.
• Write and execute your first "Hello, World!" program.
PRF193 - Introduction & Setup 3
COURSE INTRODUCTION
PROGRAMMING
C PROGRAMMING LANGUAGE
C++ PROGRAMMING LANGUAGE
COURSE INFORMATION
PROGRAMMING
PRF193
What is Programming?
•Programming is the process of
writing code (a set of instructions)
that is interpreted and executed by a
computer or other electronic
devices.
•These instructions are used to
create programs that control how
applications function and operate.
•Programmers are individuals who
write code using programming
languages to build software, solve
problems, and automate tasks.
PRF193
PRF193 - Introduction & Setup 6
C PROGRAMMING LANGUAGE
• What is the C Programming Language?
PRF193
•C is a versatile and powerful programming
language widely used in system programming
and application development.
•Provides low-level access to memory, making it ideal for creating
operating systems, hardware drivers, and embedded systems.
•Known for its simplicity, efficiency, and portability across different
platforms, contributing to its long-lasting popularity.
•The clear structure and flexibility of C make it an excellent starting
point for learning other programming languages.
PRF193
PRF193 - Introduction & Setup 8
C PROGRAMMING LANGUAGE
• Applications of C Programming Language
PRF193
PRF193 - Introduction & Setup 9
C++ PROGRAMMING LANGUAGE
PRF193
PRF193 - Introduction & Setup 10
C++ PROGRAMMING LANGUAGE
• What is C++?
PRF193
• C++ is a general-purpose
programming language evolved from
the original C language.
• Object-Oriented: Supports object-
oriented programming alongside
multiple programming paradigms.
• High-Performance Applications: Commonly used for developing
system software, games, and other performance-critical
applications.
• Advanced Features: Includes templates, exceptions, and operator
overloading for more efficient and expressive code.
• Versatility & Power: Combines the efficiency of C with additional
features to enhance productivity and scalability.
PRF193
PRF193 - Introduction & Setup 12
COMPUTER PROGRAM
• Computer Program = Data + Instructions
• A combination of data and instructions designed to solve a
PRF193
problem.
• A Simulation of a Solution
• Represents a set of instructions
that computer hardware executes
to simulate a solution.
• Purpose:
• Increase performance of standard workflows by automating
tasks and optimizing processes.
P1 P2
Computer software:
• - A set of related programs Pn
P3 Pn
PRF193
• Build robust and user-friendly interfaces.
• Correctness
• The solution must be correct and reliable.
• Perform comprehensive testing to verify accuracy.
• Maintainability
• Programs should be easy to modify and update.
• Understandability: Use clear, structured programming.
• Internal Documentation: Include detailed comments.
• Modifiability: Follow coding standards for easier updates.
• Portability
• The program should run on different platforms (CPU + OS).
• Standards compliance ensures minimal modifications are needed.
PRF193 - Introduction & Setup 14
STEPS TO DEVELOP A SOFTWARE
PRF193
PRF193 - Introduction & Setup 15
PROGRAM EVALUATION CRITERIA
PRF193
Correctness
Robustness
Usability
Portability
Maintainability
Efficiency
PRF193
• CPU Execution:
• The CPU performs operations on:
• Values stored as operands.
• Values stored at operand addresses.
• Operands:
• Can include:
• Constants
• Registers
• Primary memory addresses
PRF193
are written in assembly
language contain a large
number of statements.
• Machine Language
Assembly language High-
level languages,
• To make our programs
shorter, we use higher-level
languages.
PRF193
• Programs written in assembly language require a large number
of statements for even simple tasks.
Language Hierarchy:
• Machine Language (lowest level)
• Assembly Language (low-level, human-readable)
• High-Level Languages (C, C++, Python, etc.)
Benefits of High-Level Languages:
• Shorter and more efficient code.
• Easier to write, read, and maintain.
PRF193
languages.
• Language Efficiency Comparison
• Third-Generation Languages (3GL)
• Each statement is equivalent to 5-10 machine language
statements.
• Examples: C, C++, Java
• Fourth-Generation Languages (4GL)
• Each statement is equivalent to 30-40 machine language
statements.
• Example: SQL
PRF193
• High-level program code cannot be directly executed by the computer.
• It must be translated into binary (machine) code first.
• 2 Methods of Translation
1. Interpreting
1. Translates one statement at a time and executes immediately.
2. Uses an interpreter.
2. Compiling
1. Translates all statements into machine code first, then executes the
program as a whole.
2. Uses a compiler.
• C Language:
• Uses a compiler for translation.
PRF193 - Introduction & Setup 21
TRANSLATING AND EXECUTING A PROGRAM…
PRF193
PRF193 - Introduction & Setup 22
PREREQUISITES
• Completed EN051 or obtain 500+ TOEFL equivalent international
certificates
PRF193
PRF193 - Introduction & Setup 23
COURSE DESCRIPTION- COURSE PLAN
• 1. Introduction & Setup
• Course Introduction
PRF193
• Installing Programming Tools
• Basic Structure of C/C++ Programs
• 2. Fundamentals
• Data Types, Variables, Constants
• C/C++ Operators: Assignment, Arithmetic, Relational, Logical, Bitwise,
Ternary
• Assignments 1-3: Practice on Data Types, Variables, and Operators
• 3. Control Flow
• Decision Making: if-else, switch
• Repetition Statements: for, while, do-while
• Assignments 4-5: Practice on Decision Making & Loops
• 4. Data Handling
• Arrays, Strings, Structures, Enumerations
• Assignment 6: Practice on Arrays, Strings, Structures
PRF193
• Pointers & Arrays, Pass by Reference
• Memory Management Techniques
• Review & Progress Test 1
• 6. Object-Oriented Programming (OOP)
• Classes, Constructors, Destructors
• Access Modifiers, Encapsulation, Inheritance, Polymorphism, Exceptions
• Assignments 7-9: OOP Concepts Practice
• 7. Advanced Topics
• Data Structures & Standard Template Library (STL)
• STL: Map, Set
• Multithreading
• Files & Streams: I/O, Processing, Strings
• Assignments 10-12: Practice on Inheritance, STL, Files/Streams
• 8. Reviews & Final Assessments
• Review OOP Concepts, Streams & Files
• Progress Test 2
• Final Review & Comprehensive Assessment
PRF193 - Introduction & Setup 25
COURSE MATERIALS & TOOLS
• Course Materials & Tools
• Textbook & Online Courses
PRF193
• MOOC:
• Introduction to C Course
intro2c.sdds.ca
• Introduction to Object-Oriented Programming (C++)
intro2oop.sdds.ca
• Programming Tools
• Recommended IDE:
• Code::Blocks Download Link
PRF193
• Attend lessons regularly and stay engaged in activities.
• Participate actively in classroom discussions.
• Self-Study
• Read textbooks and materials at home to reinforce concepts.
• Review notes and practice exercises after each class.
• Assessments
• Complete chapter assessments on time, including programming
tasks and written reports.
• Team Collaboration
• Discuss topics with your teams and collaborate on projects.
• Share insights and support each other to enhance learning.
PRF193 - Introduction & Setup 27
GRADING
Maximum Score: 10
Assessment Breakdown
PRF193
• Progress Tests (Q): 20%
• 12 Assignments (A): 20%
• Practical Exam (PE): 30%
• Final Exam (FE): 30%
• Total Score Calculation:
Total Score = 0.2 * Q + 0.2 * A + 0.3 * PE + 0.3 * FE
Passing Criteria:
Every on-going assessment component >0
Practical Exam >=4
Final Examination score ≥ 4
Total score ≥ 5
PRF193
PRF193 - Introduction & Setup 29
HOW TO STUDY?
• Before Class
• Read the lesson in advance to familiarize yourself with the topic.
PRF193
• Attend lectures and stay focused.
• Listen actively, understand, and make your own notes.
• Participate actively:
Share explanations on topics.
Ask questions for clarity.
Provide extra examples beyond the textbook.
• During & After Class
• Practice exercises diligently to reinforce your understanding.
• Discuss topics with classmates directly or on forums.
• Analyze, design, and implement workshop tasks and
assignments.
• Write reports to document your findings.
• Collaboration
• Form study teams to support and learn from each other.
PRF193 - Introduction & Setup 30
ACADEMIC POLICIES
• Cheating, plagiarism and breach of copyright are serious offenses
under this Policy.
PRF193
• Cheating
• Cheating includes any form of unauthorized assistance during
tests or exams:
• Talking, peeking at another student's paper, or using any
hidden methods to transmit information.
• Plagiarism
• Using someone else’s work without proper citation.
• Presenting others' work as your own is strictly prohibited.
• Breach of Copyright
• Photocopying textbooks or any material without the copyright
holder’s permission is a violation of copyright law.
PRF193 - Introduction & Setup 31
ACADEMIC POLICIES
• Let’s Enjoy the Course! 🎉
PRF193
• Be Enthusiastic!
• The material is interesting, useful, and essential for your journey
as a software engineer.
• Learning Together
• We’re here to support you in every step. Our goal is to make this
experience enjoyable and rewarding.
• Your Role
• Stay engaged, be curious, and actively participate. Your
enthusiasm fuels the learning process!
• Have Fun with Programming
• Let’s make the most of our time together exploring the
Foundations of Programming using C/C++! 🚀
PRF193 - Introduction & Setup 32
GETTING/INSTALLING
PROGRAMMING TOOL
PROGRAMMING
C PROGRAMMING LANGUAGE
C++ PROGRAMMING LANGUAGE
COURSE INFORMATION
DEFINITIONS
• Information: Knowledge about something.
PRF193
• Data: Values that describe information; information can be
seen as the meaning of data.
• Problem Solving
• Problem: A situation where something is hidden.
• Solve a Problem: Explore and uncover the hidden information.
• Solution: The value (data) of the hidden information.
• Programming & Algorithms
• Algorithm: A method to find a solution.
• Program: A sequence of steps to implement an algorithm to
solve a problem.
• Computer Program: A program that is executed on a computer
PRF193 - Introduction & Setup 34
GETTING AND INSTALLING TOOL
• Visit the Official Site
PRF193
• Navigate to the Code::Blocks download page:
https://www.codeblocks.org/downloads/binaries
• Select the Correct Version
• Under the Windows section, choose the “mingw-setup”
variant. This all-in-one installer includes all necessary tools (IDE
+ Compiler).
• Download & Install
• Select any download link to start downloading.
• Run the installer and follow the on-screen instructions.
PRF193
• Open Code::Blocks and write your code in the editor.
• Save with a .c extension for C or .cpp extension for C++
• e.g., program.c or program.cpp.
• Compile the Program
• Use the menu option Build → Build or press Ctrl + F9 to
compile the code.
• Generate Executable
• Once compiled, an executable file is created.
• The executable can run on your operating system (Windows,
Linux, etc.).
PRF193
Declaration for library using
Entry point of C-program
PRF193
• My first program // comments introducing the
source file hello.c
• */ Multi-Line Comments
PRF193
• My first program // comments introducing the
source file hello.cpp
• */
• #include <iostream>
•int main()
•{
• cout << "This is C++" << endl;
• cout << "This is C++" ;
• return 0;
•}
PRF193 - Introduction & Setup 40
SOME NOTABLE C/C++ FEATURES
• Comments
PRF193
• Syntax: /* comment */
• Purpose: Used to document programs and enhance readability.
• Note: C/C++ compilers ignore all comments.
• Whitespace
• Used to improve program readability and show the structure of
logic.
• Ignored by C/C++ compilers.
• Case Sensitivity
• C\C++ language is case sensitive.
• Example: 'A' is different from 'a'.
• Variables like myVar and myvar are treated as distinct identifiers.
PRF193 - Introduction & Setup 41
THE MAIN() FUNCTION IN C/C++
• main() is the starting point where all C/C++ programs begin
execution.
PRF193
• The main() function:
• Is independent of its position within the program.
• Is always executed first when the program runs.
• Every C/C++ program must have a main() function.
• The content of main() is enclosed within curly braces { }.
PRF193
Preprocessor Directives • Program defined by:
• global declarations
Global Declarations
• function definitions
Function Definitions • May contain preprocessor
directives
int main () {
• Always has one function
Local Declarations
named main, may contain
others
Statements
PRF193
#include <stdio.h> Preprocessor Directive
int main () {
int y; Local Declaration
Function printf("Enter x and y: ");
scanf(&x,&y); Statements
printf("Sum is %d\n",x+y);
}
PRF193
• Example:
• #include <stdio.h>: Includes the header file stdio.h in your
code. .h stands for header file, which contains function
declarations and macro definitions.
• #include <iostream>: Includes the header for C++ input/output
functions.
• stdio.h:
• Defines standard input/output functions like:
• printf(): Outputs text to the console.
• scanf(): Reads input from the user.
• iostream (C++):
• Defines stream-based input/output objects:
• cout: Outputs text to the console (std::cout << "Hello";).
• cin: Reads input from the user (std::cin >> variable;).
PRF193 - Introduction & Setup 45
SUMMARY
• Course Overview: Gain understanding of course structure and
objectives.
PRF193
• Setup Development Tools: Install necessary IDEs like
Code::Blocks for C/C++ programming.
• Learn Program Structure: Understand basic syntax and
components of C/C++ programs.
• Write Your First Program: Create and run the first "Hello,
World!" program.