CS-114 Fundamentals of Programming
Course Overview
Dr Ayesha Zeb
Email: ayesha.zeb@ceme.nust.edu.pk
Course Overview
Course Information
Course Number and Title: CS-114 Fundamentals of Programming
Credits: 2-1
Instructor(s)-in-charge: Dr. Ayesha Zeb
Course type: Lectures, practical and demonstrations
Required or Elective: Required
Course pre-requisite(s) Nil
Degree and Semester DE-45, Semester 2
Month and Year Spring 24
Catalog Descriptions
The main objective of this course is to introduce students to basic computer
concepts and programming. At the end of this course students will be able to
write useful and efficient software programs to solve basic computing problems.
Learning Outcomes
Upon successful completion of the course, the student will demonstrate
competency by being able to:
Applying fundamental concepts of selection statements and repetition
1.
structures to solve a problem.
Understanding and implementing the concept of functions and
2.
structures in C++
3.
Design algorithms to solve complex problems using arrays and pointers.
4. To code document, test and implement a well-structured robust
computer program using C++ programming language.
Topics Covered
Topics covered in the Course and Level of Coverage
Introduction to Programming: Phases of compilation and execution, Types of 5 hrs
files and types of translators.
Variables, Data Types and Operators: Concept of variables, input and output
statements, precedence and associativity of arithmetic operators, assignment 5 hrs
operators.
Selection constructs: Relational operators and logical operators, bool data
type, single selection--if, double selection if-else, multiple selection else-if, 5 hrs
conditional expressions and switch statement.
Loops: Known repetitions ---for, Unknown repetitions --- do-while and while,
6 hrs
concept of sentinel value, nested constructs, break and continue statements.
Functions: Declaration, defining functions, comparison with library functions,
passing arguments, constants, variables, returning values from function.
Passing arguments by value and reference mechanism. Overloaded functions, 6 hrs
inline functions, default arguments. Variables and storage classes, auto,
external and static variables.
Arrays: Definition, accessing elements, initialization, one dimensional arrays,
multidimensional arrays, passing arrays to function, reinforcement of arrays in 5 hrs
conjunction with loops.
Course Targets and Grading system
Course Outcomes and their Relation to Program Outcomes
(Mapping CLO to PLO)
CLO Outcomes Level of PLO
Learning
1 Applying fundamental concepts of selection statements and C3 1
repetition structures to solve a problem.
2 Understanding and implementing the concept of functions C3 1
and structures in C++
3 Design algorithms to solve complex problems using arrays C6 3
and pointers.
4 To code document, test and implement a well-structured P-2 3
robust computer program using C++ programming language.
Course Work Lab
Finals 45% Finals 20%
Mid Term Exam 30% Mid Term Exam 10%
Projects 10% Reports/Manual 20%
Quizzes 10% Tasks 30%
Assignments 5% Project/OEL 20%
Expectations from students
o To attend classes regularly so you don’t miss quizzes.
o Submit assignments on time.
o Be attentive and ask questions.
o Always read books, if you get time, you can watch online lectures and videos.
o Never miss a lab, always perform experiment by yourself even you are working in a group, you have plenty of time for it.
o Always Read the book content of the upcoming lecture before coming to the class so you can understand and comprehend better.
This course requires combination of knowledge from your previous studied courses.
o You can expect in-class assignments during the course.
o Do study and follow the Plagiarism Policy and rules available at https://ceme.nust.edu.pk/downloads/plagiarism-policy/ .
o Class Participation in Lab will be graded, class participation means you present some topic during the lab and also help others in
doing experiments.
o Lab Projects will be in a group, each group member will be accessed individually and will be graded individually, for details see
lab course outline on LMS.
o Lectures will be on PPT, and the PPT will be shared in PDF format for students on LMS. Each lecture will contain learning
objectives for that specific lecture.
o Theory lectures will also use active-learning techniques.
o Current event and issues examples will be illustrated in the class to motivate the student’s discussion, students are welcome to
come up with the problems currently faced in the FYP and world.
o Audio/visual materials will be used in some of the classroom and laboratory lectures to help student understand the concept.
o This course will also use a flipped classroom approach.
o Students will be encouraged to participate in class-related social media pages.
o Communication with the students will be on Email and WhatsApp (Microsoft Team for online classes only).
o Following are the regular office hours in which students could see me for follow-up questions or course-related help
▪ On Tue, Wed, and Thu (10 AM-4 PM) in my office on First-Floor, DMTS
▪ You can always call me or drop a message on WhatsApp
▪ Mobile: +92-300-5520847, Office: +92-51-5444-4446,
• email: ayesha.zeb@ceme.nust.edu.pk
Lecture Contents
• Course overview
• What is computing, computers and algorithms?
• What is a program?
• What can programs do?
• How are computers organized?
• What is a programming language?
• Levels of programming languages
• Why study C++?
• Compilation steps
How to be a good programmer?
• Practice
• Practice
• Practice
• Practice
• Practice
• Practice
• Practice
• Practice
• Practice
• Practice
• Practice
• .
• .
• .
More About the Course
• Naming assignments, tasks, lab reports etc
– name_syn_assignX
– name_syn_taskX
– name_syn_labreportX
– X is the number of the task, assignment, lab report etc
• Plagiarism will be taken very seriously
Plagiarism
• What is plagiarism
– Sharing code: by copying, retyping, looking at or
supplying a file
– Coaching: helping your friend in lab line by line
– Copying code from previous courses or from the web
• What is not plagiarism
– Explaining how to use tools
– Helping others with concepts
– Borrowing snippets of code/ideas from the web or
other sources with proper references/citations/credit
Email Etiquette
• Subject
– [CS114]-Name-Topic
– For example [CS114]-Fatma-LMSNotWorking
• Body
– Please use proper English: no slang, no urdu
• Please make sure the email includes your name.
• I will not entertain emails that do not follow these
guidelines!
Misc
• Submit Lab Reports
• If you don’t submit the lab report you may receive partial
to 0 credit for your lab tasks
• Submit Assignments
• If you don’t submit assignments you may receive partial
to 0 credit for quizzes and project
• I like putting parts of assignments, lab tasks, quizzes in
sessionals and the final
Misc
• Don’t plagiarize
• If you don’t understand, ASK
• Communicate your hardwork (it always shows!!)
• Start on assignments early, they’re meant to take the time they’ve
been allotted and NOT 5 hours
• Don’t plagiarize
• BE RESPONSIBLE!!!
• I will NOT move deadlines
• All assignments and reports need to be typeset
Class room etiquettes
• Do be present in body and mind!
• Do arrive on time! No attendance after 10 mins.
• Do stay for the whole class!
• Do be prepared for class!
• Do put cell phones away and on vibrate…Texting should not be going on in
class!
• Do stay awake and be attentive!
• Do show effort, try your best, ask for help!
• Avoid use of Mobile phone, Laptops or any gadgets
• Obedience to all laws, discipline code, rules and community norms
• Respect peers, faculty and staff through actions and speech
• Student should not be sleeping during class
• Bring writing material and books
• Class participation is encouraged
Why should we respect our teachers?
• Your teachers spend hours weekly preparing for your class
• They think, plan, and create lessons to help you learn
• They want you to learn and care about you and your education
• They can help you in future
• They cannot control everything, they have to deal with a lot of things
• They are not out to get you.
• And most importantly, they have been in your shoes!!!!
Teachers are not information providers,
they are knowledge facilitators
About You
• Don’t tell us your name
• Tell us how you like or dislike EME
• Tell us what you think this course will teach you
• Tell us the name of the person next to you and one thing
about them you think they’re really proud of
Lab Today
• Introduction to Visual Studio
What is Computing?
“Computing is the study of how computers and computer
systems work and how they are constructed and
programmed.”
“Computing is any goal-oriented activity requiring, benefiting
from, or creating algorithmic processes - e.g. through
computers. “
http://www.computingatschool.org.uk/index.php?id=what-is-computing and Wikipedia
What is a Computer?
• A general purpose device
• Can automatically perform
– Arithmetic operations
– Logical operations
• Computers are great at
performing calculations!!
• They always follow the
formula and so they can’t
make mistakes!
What is a Computer?
• Lots and lots of on off switches
– Transistors
• Work really fast to perform operations
• A single small operation is called an instruction
• The speed of a computer represents how many
instructions it can perform
• Speed is measured in hertz
What is a Computer
• [2011] A
supercomputer can
do in a day what a
dual-core personal
computer would take
160 years to
complete
[techradar.com] Tianhe-2, aka Milky Way 2
Tianhe-2, a supercomputer developed
by China's National University of
Defense Technology is the fastest
supercomputer in the world
[zdnet.com]
What is an Algorithm ?
• Computers perform a series of instructions.
• Each step is performed without any thought – mechanical.
• A series of mechanical steps make an algorithm.
• An algorithm is a mechanical procedure that is
guaranteed to eventually finish.
• More on this later
Computers are everywhere!!!
• Your RFID cards
• E-Tag
• Your phone!!
• The LMS
How do we tell computers what to do??
• We give them a series of instructions – programs
• How do we give them these instructions:
– Programming Languages
• Lots of programs together make SOFTWARE
What can programs do?
Solve equations
Touch Up Images Cure diseases
http://www.wolframalpha.com/examples/?src=input
What can programs do?
• Facebook
• Google
• Wikipedia
• The internet!!!
What can programs do?
What can programs do?
BMW testing a self driving car Google’s self driving car
What can programs do?
3D Printing
What can programs do?
Why learn to program??
• Problem solving
• Planning – a lot of thinking about what
you have to do and how
• Learning complex concepts
• Different perspectives – cross disciplinary
(arts, social sciences, physics, maths,
chemistry, biology etc)
• It’s super fun!!
• You can get a great job!!
How do Computers Work?
How do Computers Work?
• Inputs provide data
• Processes perform
operations on data
• Outputs display/show
the result of the
operations performed
How do Computers Work?
• Hardware: devices
(cables, keyboard,
screen, printer,
processor)
• Software: the
program that
performs
operations
How are Computers Organized?
• The memory unit that holds both
data and instructions.
• The arithmetic/logic gate unit
that is capable of performing
arithmetic and logic operations
on data.
• The input unit that moves data
from the outside world into the
computer.
• The output unit that moves
results from inside the computer
to the outside world.
• The control unit that acts as the
stage unit to ensure that all the
other components act in concert.
How are Computers Organized?
1.Input unit
It obtains data and computer programs from input devices for
example, keyboards, mouse, camera, etc.
2.Output unit.
It takes processed information and places it on various output
devices to make the information available for use outside the
computer. For example, monitors, screen, printer or can be used
to control other devices.
3.Memory unit.
It stores computer programs while they are being executed.
However, the memory unit only stores information temporarily.
RAM is a part of the memory unit.
4. Arithmetic and logic unit (ALU).
It is responsible for performing calculations, such as addition,
subtraction, multiplication and division and for checking whether two
numbers are equal.
How are Computers Organized?
5. Central processing unit (CPU).
It coordinates and supervises the operation of the other sections. The CPU
tells the input unit when information should be read into the memory unit, tells
the ALU when information from the memory unit should be used in
calculations and tells the output unit when to send information from the
memory unit to certain output devices.
6. Secondary storage unit.
Programs or data not actively being used by the other units normally are
placed on secondary storage devices, such as CDs or DVDs until they are
again needed.
7. Control unit.
The control unit (CU) is a component of a computer's central processing unit (CPU)
that directs operation of the processor. It tells the
computer's memory, arithmetic/logic unit and input and output devices how to
respond to a program's instructions.
Computers in World War II
A Colossus Mark 2 computer being operated
by Dorothy Du Boisson(left) and Elsie Booker.
The slanted control panel on the left was used
to set the "pin" (or "cam") patterns of the
Lorenz. The "bedstead" paper tape transport
is on the right. [Wikipedia]
An intercept sheet of German radio transmission
created for the cryptologists at Bletchley Park,
Buckinghamshire, England, United Kingdom, date
unknown
[http://ww2db.com/battle_spec.php?battle_id=92]
Programming Languages
Some programming languages
Programming Languages
• Program: a set of instructions for a computer to execute
• Programming Language: A set of rules, symbols, and
special words used to construct a computer program.
Programming Languages
• Machine Language
– Based on machine's core instruction set.
– Needed by computer, hard for humans to read (1's and 0's).
– Example: 1110110101010110001101010
– Say what?
• Assembly Language
– Translation of machine instructions to symbols, slightly easier for
humans to read
– Example: ADD $R1, $R2, $R3
– Well, we know it has something to do with addition!
• High-level procedural languages
– Abstraction of concepts into more human-readable terms
– Closer to "natural language" (i.e. what we speak)
– Easy to write and design, but must be translated for computer
– Examples include C, Pascal, Fortran: c=a+b
Programming Languages
• Object-oriented languages:
– Abstraction taken farther than procedural languages
– Objects model real-world objects, not only storing data
(attributes), but having inherent behaviors (operations, functions)
– Easier to design and write good, portable, maintainable code
– Examples include Smalltalk, C++, Java
Why C++ ?
• Widely
used
• Not very
hard, not
very easy
• Gives you
insight into
your
computer
Companies and Programs that Use C++
History of C++
BC Languages such as FORTRAN, COBOL,
ALGOL, PL/I and others.An official C++
standard is adopted.
1970 Brian Kernigham and Dennis Ritchie invent
C. The language they used for inspiration
was called “ B”
1980 Bjarne Stroustrup created “C with Classes.”
1995 The ANSI Committee releases their draft of
the C++ Standard.
1998 An official C++ standard is adopted.
Dennis Ritchie
(1941-2011)
Sidenote on C
• Windows is an operating system
• An operating system is
– A set of programs/instructions that take care of dealing with the
very basic operations related to inputs, outputs and processes.
• The “core” of windows was programmed in C
• The rest of it is in C++
• Other operating systems include Mac, Linux, Unix – all in
C, with some other languages!
Sidenote
Applications (Browser,
Games etc) Software
Operating System (Windows,
Linux, Mac OS etc)
Hard Drive Monitor Hardware
C++ Standards
Year Standard
1989 C++ 2.0
1998 C++98
A standard includes generalized
rules that make sure the language 2003 C++03
is the same across different 2007 C++TR1
platforms all over the world 2011 C++11
2014 C++14 (C++1y)
2017 C++17
2020 C++20
Compilation: From High-level language to
machine language
• Interpreted languages
– Source code (what the programmer writes) is directly run on an
interpreter (converts each line to machine language)
• Compiled Languages
– A compiler program translates source code (what the
programmer writes) to machine language (object code)
– A linker program puts various object code files together into an
executable program (or other target type, like a DLL)
– C and C++ are compiled languages
Compilation
• Source Program
– A program written in a human readable version, which you will
write.
• Object Program
– The machine language version of a source program in 0s and
1s.
• EXE Program
– It is an executable program
Compilation
Compilation
Demo
//A simple program that displays Hello 44 MTS to the screen
#include <iostream> //the input output stream library
using namespace std; //the using directive tells us that
we’re going to be using things from
the library "namespace" with a prefix
std
int main()
{
//displaying Hello 44 MTS
cout << "Hello 45 MTS!" << endl;
//send back a code to the OS, saying everything worked out
well
return 0;
}
Demo
//A simple program that displays Hello 44 MTS to cout << "Hello
the screen 45 MTS!" <<
endl;
#include <iostream>//the input output stream
library
using namespace std;//the using directive tells us
that we're going to be using
things from the library
"namespace" with a prefix std
int main()
{
//displaying Hello 44 MTS
cout << "Hello 45 MTS!" << endl;
//send back a code to the OS, saying
everything worked out well
return 0;
}
Acknowledgement/References
• Slides prepared by Dr Ayesha Zeb
• Deital and Deital, “C++ How to Program”, Latest Edition
• Stroustrup, “Programming – Principles and Practice
Using C++”, Latest Edition