0% found this document useful (0 votes)
6 views17 pages

Introduction From Problem Analysis To Design Class Notes For Programming Students

The document provides an introduction to computer programming including prerequisites, textbooks, course outline, history of programming languages, processing C++ programs, and an example for finding the perimeter and area of a rectangle.

Uploaded by

www.meshukhan72
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views17 pages

Introduction From Problem Analysis To Design Class Notes For Programming Students

The document provides an introduction to computer programming including prerequisites, textbooks, course outline, history of programming languages, processing C++ programs, and an example for finding the perimeter and area of a rectangle.

Uploaded by

www.meshukhan72
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

INTRODUCTION TO

COMPUTER
PROGRAMMING
Sonam Yar
Lecturer Computer Science
Pre-requisite

• Introduction to Computer Science


Text books and References

• C++ Programming: From problem analysis to program design, 2 nd Edition


by D.S. Malik

• Object oriented programming in C++, 4th Edition, by Robert Lafore


Email Id

[email protected]
Course Outline
• Programming and Problem analysis
• Flow charts
• Development of basic algorithms
• Translation of algorithms into programs
• Structured Programming
• Object Oriented Programming
 Standard data types
 Basic control structures
 Functions
 Structured data types
 Arrays
 Structures
 Pointer and files
• Testing and debugging
Brief History of Programming
Languages
• Computer rely on directions to do any task
• These directions are called programs.
• People who write programs are called programmers.
• Programmers use a variety of special languages called programming
languages to communicate with the computer.
The Evolution of Programming Languages
(cont'd.)
• High-level languages include Basic, FORTRAN, COBOL, Pascal, C, C++, C#, and
Java
• Compiler: translates a program written in a high-level language machine language
Processing a C++ Program

#include <iostream>
using namespace std;
int main()
{
cout << "My first C++ program." << endl;
return 0;
}

Sample Run:
My first C++ program.
Processing a C++ Program (cont'd.)

To execute a C++ program:


• Use an editor to create a source program in C++
• Preprocessor directives begin with #
• Use the compiler to:
• Check that the program obeys the rules
• Translate the program into machine language (object
program)
Processing a C++ Program (cont'd.)

To execute a C++ program (cont'd.):


• Linker:
Combines object program with other programs provided by
the SDK to create executable code
• Loader:
Loads executable program into main memory
The last step is to execute the program
We use instead an IDE having both editor and compiler
along with other features
Processing a C++ Program (cont'd.)
Programming with the Problem Analysis–Coding–
Execution Cycle
• Programming is a process of problem solving
• problem-solving technique:
• Analyze the problem
• Outline the problem requirements
• Design steps (algorithm) to solve the problem
• Algorithm:
• Step-by-step problem-solving process
• Solution achieved in finite amount of time
The Problem Analysis–Coding–Execution
Cycle (cont’d.)x
The Problem Analysis–Coding–Execution
Cycle (cont'd.)
• Run code through compiler
• If compiler generates errors
• Look at code and remove errors
• Run code again through compiler
• If there are no syntax errors
• Compiler generates equivalent machine code
• Linker links machine code with system resources

C++ Programming: From Problem Analysis to Program Design, Fifth Edition


The Problem Analysis–Coding–Execution
Cycle (cont'd.)
• Once compiled and linked, loader can place program into main
memory for execution
• The final step is to execute the program
• Compiler guarantees that the program follows the rules of the
language
• Does not guarantee that the program will run correctly
Example 1-1
• Design an algorithm to find the perimeter and area of a rectangle
• The perimeter and area of the rectangle are given by the following formulas:

perimeter = 2 * (length + width)


area = length * width
Example 1-1 (cont'd.)

• Algorithm:
• Get length of the rectangle
• Get width of the rectangle
• Find the perimeter using the following equation:

perimeter = 2 * (length + width)


• Find the area using the following equation:

area = length * width

You might also like