Professional Documents
Culture Documents
Topics Programming
1.1 What is Computer & its applications?
1.2 Why Program? Computer Programming
1.3 Computer Systems: Hardware and Software
for Manufacturing Engineering 2nd
1.4 Programs and Programming Languages
year
1.5 Software development phases
1.6 Software development Process by Gebriye E.
1.7 Programming Languages Computer Science Department
1.8 C++ Program Compilation process
Gebriye Embafresu Computer Science Department 1-4 Gebriye Embafresu Computer Science Department 1-3
1.1.1 Application of Computer… 1.1.1 Application of Computer…
At Home: People use Computers for tasks such as At Work: People use Computers
➢ Paying bills ➢ To analyze data
➢ Shopping online ➢ Make presentations
➢ Social networking (Facebook, imo, telegram, ➢ Make business transactions
twitter, YouTube) ➢ Communicate with customers and coworkers
➢ and playing games ➢ Control machines in manufacturing facilities and
SO, the use Computers are almost limitless in our do many other things.
everyday lives, because they are programmable.
Gebriye Embafresu Computer Science Department 1-6 Gebriye Embafresu Computer Science Department 1-5
Gebriye Embafresu Computer Science Department 1-10 Gebriye Embafresu Computer Science Department 1-9
Gebriye Embafresu Computer Science Department 1-14 Gebriye Embafresu Computer Science Department 1-13
Gebriye Embafresu Computer Science Department 1-16 Gebriye Embafresu Computer Science Department 1-15
Example Program 1.4.1 What Is a Program Made Of?
#include <iostream>
using namespace std; There are common elements in most
programming languages
int main()
{ 1) Language elements:
double num1 = 5, – Key Words
num2, sum; – Programmer-Defined Identifiers
num2 = 12;
– Operators
sum = num1 + num2; – Punctuation
cout << "The sum is " << sum; – Syntax
return 0;
}
Gebriye Embafresu Computer Science Department 1-18 Gebriye Embafresu Computer Science Department 1-17
Gebriye Embafresu Computer Science Department 1-20 Gebriye Embafresu Computer Science Department 1-19
Punctuation Operators
• Characters that mark the end of a • Used to perform operations on data
statement, or that separate items in a list • Many types of operators
• Example in program (shown in green): – Arithmetic: +, -, *, /
double num1 = 5, – Assignment: =
num2, sum;
num2 = 12; • Examples in program (shown in green):
num2 = 12;
sum = num1 + num2;
Gebriye Embafresu Computer Science Department 1-22 Gebriye Embafresu Computer Science Department 1-21
Gebriye Embafresu Computer Science Department 1-26 Gebriye Embafresu Computer Science Department 1-25
Gebriye Embafresu Computer Science Department Gebriye Embafresu Computer Science Department
3. Design
• The next step is to design a method of solution 2. Analysis
for the problem. – In the analysis phase we should identify the
• A method of solution is also called algorithm following:
• Algorithm is a series of steps to be performed • Inputs to the problem, their form, and the input
media to be used
in a specific logical order.
• Outputs expected from the solution, their form,
• Algorithm can be designed by using either: and the output media to be used
– Pseudo codes or • Any special constraints or conditions
– Flow charts • Formulas or equations to be used
Gebriye Embafresu Computer Science Department Gebriye Embafresu Computer Science Department
Gebriye Embafresu Computer Science Department Gebriye Embafresu Computer Science Department
6. Program Documentation • Testing the program consists of :
• Prepare documents that explain
– how the program works and
– Desk-checking- is simply reading through, or
– how to use it. checking the program to make sure that it is
• Program documentation consists of these elements: free of errors and that the logic works
– A concise requirements specification. – Debugging the program- means to detect,
– Descriptions of problem inputs, expected outputs, constraints, locate and remove all errors in a computer
and applicable formula
– A pseudocode or flowchart for its algorithm.
program
– A source program listing. – Run real-world data
– A hard copy of a sample test runs of the program. • Testing the program with real data and real users
– A user’s guide explaining to non programmer users how the • It is also advisable to test it with faulty or
program should be used.
incomplete or overwhelming data
Gebriye Embafresu Computer Science Department Gebriye Embafresu Computer Science Department
Gebriye Embafresu Computer Science Department Gebriye Embafresu Computer Science Department
Examples… Examples
4 . Wait for the user to enter an hourly pay rate . • suppose we want the computer to calculate
Once the user enters a number, store it in memory someone's gross pay. Here is a list of things the
computer might do:
5 . Multiply the number of hours by the amount 1. Display a message on the screen asking "How
paid per hour, and store the result in memory many hours did you work?"
2. Wait for the user to enter the number of hours
6. Display a message on the screen that tells the worked . Once the user enters a
amount of money earned. The message must number, store it in memory.
include the result of the calculation performed in 3. Display a message on the screen asking "How
step 5 much do you get paid per hour?"
Gebriye Embafresu Computer Science Department 1-40 Gebriye Embafresu Computer Science Department 1-39
Examples
• Example:1 The following set of instructions forms
a detailed algorithm in pseudo code for
calculating the payment of person.
• Input the three values into the variables Name,
Hours, Rate.
• Calculate Pay = Hours ´ Rate.
• Display Name and Pay.
Gebriye Embafresu Computer Science Department Gebriye Embafresu Computer Science Department
Gebriye Embafresu Computer Science Department Gebriye Embafresu Computer Science Department
Gebriye Embafresu Computer Science Department Gebriye Embafresu Computer Science Department
Characteristics of HIGH Level Languages: 2. High-level languages
• They are not machine oriented:
– they are portable, meaning that a program written for one • They permit faster development of large
machine will run on any other machine for which the appropriate
compiler or interpreter is available. programs.
• They are problem oriented:
– most high level languages have structures and facilities • The final program as executed by the
appropriate to a particular use or type of problem.
– For example, FORTRAN was developed for use in solving computer is not as efficient.
mathematical problems. Some languages, such as PASCAL
were developed as general-purpose languages. • closer to human language
• Statements in high-level languages usually resemble
English sentences or mathematical expressions Eg. BASIC, COBOL, FORTRAN, C, C++, C#,
– they tend to be easier to learn and understand than
assembly language. JAVA, JavaScript, Pascal
• Each statement in a high level language will be
translated into several machine code instructions.
Gebriye Embafresu Computer Science Department Gebriye Embafresu Computer Science Department
Gebriye Embafresu Computer Science Department Gebriye Embafresu Computer Science Department
Gebriye Embafresu Computer Science Department Gebriye Embafresu Computer Science Department
End of Chapter One