0% found this document useful (0 votes)
2 views

Lecture 1 Introduction

The document outlines a computer programming course led by Dr. Arif Ur Rahman, covering essential topics such as programming concepts, software types, programming languages, and C++ specifics. It includes course information, learning outcomes, grading policies, and guidelines for effective communication. Additionally, it provides insights into programming paradigms, software development activities, and common errors encountered in programming.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lecture 1 Introduction

The document outlines a computer programming course led by Dr. Arif Ur Rahman, covering essential topics such as programming concepts, software types, programming languages, and C++ specifics. It includes course information, learning outcomes, grading policies, and guidelines for effective communication. Additionally, it provides insights into programming paradigms, software development activities, and common errors encountered in programming.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 50

Computer Programming

Introduction

Week 01 Sp 25

Acknowledgement – Ms. Nabia Khalid worked on the slides


Hello!
I am Dr.Arif Ur
Rahman
Office: Near Faculty Cafeteria – Cubical F
Time: Everyday after 2PM
You can reach me at [email protected]

2
Acknowledgement – Ms. Nabia Khalid worked on the slides
Communication
[email protected]
Ettiquette

◉ How to communicate via email?

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%

C+: 64-67, Mid Semester Exam;


20%
C: 60-63, 20%

C-: 57-59, Quizzes; 10% Assignment; 10% Term Project; 10%


10%
D+: 53-56,
D: 50-52, 0%

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?

A computer program is a well


defined, unambiguous and
finite set of instructions given
to a computer to solve a
particular problem!
Computer Software
• A Computer software, is the collection of computer programs and
related data that provide the instructions telling a computer what to
do

• 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

Only language computer directly understands . It is called the


“Natural language” of a computer
Defined by hardware design
Each kind of CPU has its own machine language
Generally consist of strings of numbers
Ultimately 0s and 1s
Instruct computers to perform elementary operations
Cumbersome for humans
1010 0001 0000 0000 0000 0000
0000 0011 0000 0110 0000 0000 0000 0010
1010 0011 0000 0000 0000 0000
Assembly Language

• English-like abbreviations representing elementary computer operations


• Clearer to humans
• Incomprehensible to computers
• Convert to machine language by translator programs (assemblers)
• Example

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

grossPay = basePay + overTimePay


Programming Paradigms

• Different programming languages follow different approaches to


solving programming problems
• A programming paradigm is an approach to solving programming
problems.
• A programming paradigm may consist of many programming
languages.
• Common programming paradigms:
• Imperative or Procedural Programming
• Object-Oriented Programming
Programming Paradigms-contd.

• 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

• object oriented languages include: Java, C++, C#, Smalltalk, etc


Why choosing C++?
• You can’t learn to program without a programming language
• The purpose of a programming language is to allow you to express
your ideas in code
• C++ is the language that most directly allows you to express ideas
from the largest number of application areas
• C++ is the most widely used language in engineering areas
• Programming concepts that you learn using C++ can be used fairly
directly in other languages
• Including C, Java, C#, and (less directly) Fortran
Why choosing C++?
• In today’s ✈️AI-driven world, many students wonder 🫢 why we learn C++ instead of Python or Java,
which is widely used in AI, data science, and machine learning.

• 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!!

• // my first program in C++

• #include <iostream>
• using namespace std;
• void main()
•{
• cout << "Hello …";
•}
Integrated Development Environment-IDE

Integrated Development Environments or IDEs supports the entire


software development cycle
E.g., MS Visual C++, Borland
Provides all the capabilities for developing software
Editor
Compiler
Linker
Loader
Debugger
Viewer

Task: Install Microsoft Visual Studio 2017/2019


https://visualstudio.microsoft.com/downloads/
Errors or Bugs

• 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" ;
•}

Linker Error: Undefined Symbol _main


Run-time Error
• #include <iostream>
• using namespace std;
• void main(void)
•{
• int myValue = 0;
• int yourValue = 10;
• double value = yourValue / myValue;
•}
These errors don’t reveal themselves until the program executes.
Conceptual Errors
• #include <iostream>
• using namespace std;
• void main(void)
• {
• int value1 = 4;
• int value2 = 10;
• int value3 = value2 / value1;
• cout << "Result =" << value3;
• }

The program is not doing what you expect it to do.


Writing first C++ Program!!
1 // Fig. 2.1: fig02_01.cpp
2 // Text-printing program.
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 to C++!\n"; // display message
9
10 return 0; // indicate that program ended successfully
11

12 } // end function main

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

• Standard output stream object


• std::cout
• “Connected” to screen
• Defined in input/output stream header file <iostream>
Writing First C++ Program!!
• Stream insertion operator <<
• Value to right (right operand) inserted into left operand
• Example
• std::cout << "Hello";
• Inserts the string "Hello" into the standard output
• Displays to the screen

• 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

13 } // end function main

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

12 } // end function main

Welcome
to

C++!
Task!!

• How to generate the following output:

******************
Name
My name
Enrollment No
My Enrollment No
**************

You might also like