Lecture 1 Introduction
Lecture 1 Introduction
Introduction
Week 01 Sp 25
2
Acknowledgement – Ms. Nabia Khalid worked on the slides
Communication
[email protected]
Ettiquette
nse
◉
spo
No slang
e
ny r
◉ Neutral attitude
ct a
e
exp
◉ Structure
n ot
do
○ Clear subject
is e ,
○
er w
Greetings
Ot h
○ Description of yourself
○ Description of the issue
○ What have you done to address the issue so
far
○ What do you expect from me
○ Closing
Arif Ur Rahman, BUIC 3
Scope!
• Course Information
• Course Learning Outcomes
• Course Outline
• Grading Policy
• How to survive in a programming course?
• What is a program?
• Computer Software
• Types of programming languages
• Programming paradigms
• Software development activities
• Program errors/ Bugs
• Writing FIRST PROGRAM IN C++
Course Information
Course Learning Outcomes
1. Demonstrate the understanding of the basic concepts of
programming.
2. Exhibit logic building ability using basic programming concepts.
3. Apply programming concepts to model requirements and solve
computing problems using a high-level programming language.
Text Books
Text Books
Course Outline
• Introduction to programming
• Problem solving basics
• Programming Process
• C++ program structure
• Basic data types and variables declaration
• Arithmetic expressions and operators
• Control statements
• Functions
• Arrays and Strings
• Pointers
• Advanced Data Types (Structures)
• Basics of Class concept
Class Composition
Lectures (Slides +Handouts)
Quizzes
Assignments
Term Project
Grading policy
60%
A: 85-100,
A-: 80-84, 50%
Final Exam; 50%
B+: 75-79,
40%
B: 71-74,
B-: 68-70, 30%
F: 0-49 Quizzes Assignment Term Project Mid Semester Exam Final Exam
Credits : 3+1
How to survive a programming course?
Course of Action!
• Write your programs on your machine
• Compile
• Debug
• Execute
Can you name any programming languages?
What is a computer program?
• System Software
• Application Software
System Software
• Provides the basic function for computer usage
• Programs that support the execution and development of other programs
• Operating Systems – Windows, Linux, MAC
• Tranlsation Systems
• Set of programs used to develop software
• Compilers, Assemblers etc.
Application Software
• Developed for some certain purpose/application
• Examples
• Word processors
• Spreadsheets
• Presentation managers
• Drawing programs
Types of programming languages?
Machine Language
load basepay
add overpay
store grosspay
High-level Languages
• Similar to everyday English
• Uses common mathematical notations
• Single statements accomplish substantial tasks
• Assembly language requires many instructions to accomplish simple tasks
• Converted to machine language by translator programs (compilers)
• Popular HLL: C, C++, Java, FORTRAN, C#
• Example
• Procedural
• In this paradigm, a program is a series of statements containing variables.
• Program execution involves changing the memory contents of the computer
continuously.
• Example of imperative languages are: C, FORTRAN, Pascal, COBOL etc
Programming Paradigms-contd.
• Object Oriented Paradigm
• A program in this paradigm consists of objects having a set of attributes and
which communicate with each other by sending messages
• The reason is to build a strong foundation. C++ teaches important concepts like memory management,
object-oriented programming, and efficient coding, which are essential for understanding
programming at a deeper level.
• C++ also helps develop problem-solving skills that can be used with any language, including Python or
Java.
• C++ is widely used in areas like game engines 🎮, embedded systems, database management, scientific
computing, compilers, and networking systems because of its speed, flexibility, and low-level control.
• Learning C++ first isn’t about ignoring Python or Java—it’s about mastering the basics to become
skilled programmers ready to tackle any challenge.
Software Development Activities
• Editing
• Compiling
• Linking with precompiled files
• Object files
• Library modules
• Loading and executing
• Viewing the behavior of the program
Software Development Activities-
contd.
Source Program
Compile
Library routines
Edit Link
Other object files
Think Load
Execute
Sample Program!!
• #include <iostream>
• using namespace std;
• void main()
•{
• cout << "Hello …";
•}
Integrated Development Environment-IDE
• Compiler Errors
• Linker Errors
• Run-time Errors
• Conceptual Errors
Compiler Error
// My first C++ program
#include <iostream>
using namespace std;
void main()
{
cout << "Hello World!\n"
}
Error Test.cpp 4: Statement Missing ; in function main()
Error Test.cpp 4: Compound Statement missing } in function main()
Linker Error
• // My first C++ program
• #include <iostream>
• using namespace std;
• void Main()
•{
• cout << "Hello World!\n" ;
•}
Welcome to C++!
Writing First C++ Program!!
• Comments
• Explain programs to other programmers
• Improve program readability
• Ignored by compiler
• Single-line comment
• Begin with //
• Example
• // This is a text-printing program.
• Multi-line comment
• Start with /*
• End with */
Writing First C++ Program!!
• Preprocessor directives
• Processed by preprocessor before compiling
• Begin with #
• Example
• #include <iostream>
• Tells preprocessor to include the input/output stream header file <iostream>
• White space
• Blank lines, space characters and tabs
• Used to make programs easier to read
• Ignored by the compiler
Writing First C++ Program!!
• Namespace
• std::
• Specifies using a name that belongs to “namespace” std
• A namespace is an abstract container or environment created to hold a logical grouping
• Escape characters
• A character preceded by "\"
• Indicates “special” character output
• Example
• "\n" Cursor moves to beginning of next line on the screen
Writing First C++ Program!!
• return statement
• One of several means to exit a function
• When used at the end of main
• The value 0 indicates the program terminated successfully
• Example
• return 0;
Escape Sequences
Escape Description
sequence
\n Newline. Position the screen cursor to the beginning of the next line.
\t Horizontal tab. Move the screen cursor to the next tab stop.
Carriage return. Position the screen cursor to the beginning of the current
\r
line; do not advance to the next line.
\a Alert. Sound the system bell.
\\ Backslash. Used to print a backslash character.
\' Single quote. Use to print a single quote character.
\" Double quote. Used to print a double quote character.
Two Examples of Printing!!
1 // Fig. 2.3: fig02_03.cpp
2 // Printing a line of text with multiple statements.
3 #include <iostream> // allows program to output data to the screen
4
5 // function main begins program execution
6 int main()
7 {
8 std::cout << "Welcome ";
9 std::cout << "to C++!\n";
10
11 return 0; // indicate that program ended successfully
12
Welcome to C++!
1 // Fig. 2.4: fig02_04.cpp
2 // Printing multiple lines of text with a single statement.
3 #include <iostream> // allows program to output data to the screen
4
5 // function main begins program execution
6 int main()
7 {
8 std::cout << "Welcome\nto\n\nC++!\n";
9
10 return 0; // indicate that program ended successfully
11
Welcome
to
C++!
Task!!
******************
Name
My name
Enrollment No
My Enrollment No
**************