19
Computing Systems & Programming ECE 1113

Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

Embed Size (px)

Citation preview

Page 1: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

Computing Systems &Programming

ECE 1113

Page 2: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

Fundamental Concepts

Chapter 1

Engineering Problem Solving

Page 3: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

Contents

Computing Systems Types of Computers Computer Hardware Computer Software Executing a Computer Program Key Terms The C Programming Language An Engineering Problem-Solving Methodology First C Program

Page 4: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

Computing Systems: Hardware and Software A computer is a machine designed to perform

operations specified with a set of instructions called a program.

Hardware refers to the computer equipment. keyboard, mouse, terminal, hard disk, printer

Software refers to the programs that describe the steps we want the computer to perform.

Page 5: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

Types of Computers Supercomputers

-the largest and fastest-used primarily for large scientific or military calculations-occupy a room or rooms space-very expensive

Page 6: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

Mainframe computers-not as fast or as large as supercomputers-usually take up a portion of a room -can be accessed from remote locations on campus

Minicomputers-less powerful than mainframes -inexpensive enough to be owned by a small businesses

Workstations-can be as powerful as minicomputers-used for engineering applications (CAD/CAM), desktop publishing, software development, which require a moderate amount of computing power & high quality graphic.

Personal computers, Laptops & Palmtops

Page 7: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

Computer Hardware

CPU - Central processing unit ALU - Arithmetic and logic unit ROM - Read only memory RAM - Random access memory

CPU

InternalMemory

ExternalMemory

Input Output

Processor

ALU

Page 8: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

Computer Software

texttexttext

Hardware

(PC, Macintosh, Sun,.....)

Operating System

(Unix, DOS, Windows,..)

Application Software

(Compilers, word processors, ..)

User

Page 9: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

Computer Software Operating System - Provides an interface with the user

unix, windows, linux, ... Software Tools

word processors (MicrosoftWord, WordPerfect, ...) spreadsheet programs (Excel, Lotus1-2-3, ...) mathematical computation tools (MATLAB, Mathematica, ...)

Computer Languages machine language assembly language binary language high level languages (C, C++, Ada, Fortran, Basic, java)

Page 10: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

Executing a Computer Program

Compiler Converts source program to object program

Linker Converts object program to executable

program

Compile Link/load ExecuteC languageprogram

Machinelanguageprogram

Program output

Input data

Page 11: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

Programming Errors

Compile-time errors (compiler error) easy to debug

Execution errors/run-time errors/logic error Error during linking or loading hard to debug might course your program to stop

execute or not stop the program from executing

the computer will perform step precisely as we specify (wrong specification, wrong execution)

Page 12: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

Key Terms

Source Program printable/Readable Program file

Object Program nonprintable machine readable file

Executable Program nonprintable executable code

Syntax errors reported by the compiler

Linker errors reported by the linker

Execution/Run-time errors reported by the operating system

Logic errors not reported

Page 13: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

The C Programming Language

General purpose, machine-independent language (portable between different computers and processors)

Developed at Bell Labs in 1972 by Dennis Ritchie American National Standards Institute(ANSI) approved ANSI C

standard in 1989 Useful for operating systems and low level computer applications Closely related to the hardware architecture and can be implemented to

give high speed and small executable code. Has a wide set of facilities for data operations and control structures.

Page 14: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

An Engineering Problem-Solving Methodology

1. PROBLEM STATEMENT

2. INPUT/OUTPUT DESCRIPTION

3. HAND EXAMPLE

4. ALGORITHM DEVELOPMENT

5. TESTING

Page 15: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

PROBLEM STATEMENT-State the problem clearly

INPUT/OUTPUT DESCRIPTION-Describe the input and output information

HAND EXAMPLE-Work the problem by hand (or with calculator) for a

simple set of data

ALGORITHM DEVELOPMENT-Develop a solution and convert it to a computer program

TESTING-Test the solution with a variety of data & compare with hand example

Page 16: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

Example1

Problem StatementCompute the straight-line distance between twopoints in a planeInput/Output Description

Hand Example

Point1

Point2 Distance between points

Page 17: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

Algorithm Development

/*---------------------------------------------------*//* Program chapter1_1 *//* *//* This program computes the *//* distance between two points. */

#include <stdio.h>#include <math.h>

int main(void){ /* Declare and initialize variables. */ double x1=1, y1=5, x2=4, y2=7,

side_1, side_2, distance;

/* Compute sides of a right triangle. */ side_1 = x2 - x1; side_2 = y2 - y1; distance = sqrt(side_1*side_1 + side_2*side_2);

/* Print distance. */ printf("The distance between the two points is "

"%5.2f \n",distance);

/* Exit program. */ return 0;}/*---------------------------------------------------*/

Page 18: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

Testing

Compare the result that you have

calculated with the result from your

program.

Page 19: Computing Systems & Programming ECE 1113. Fundamental Concepts Chapter 1 Engineering Problem Solving

First Program - sum two numbers/******************************************************************//* Program chapter1 *//* *//* This program computes the sum two numbers */

#include <stdio.h>int main(void){ /* Declare and initialize variables. */ double number1 = 473.91, number2 = 45.7, sum;

/* Calculate sum. */ sum = number1 + number2;

/* Print the sum. */ printf(“The sum is %5.2f \n”, sum);

/* Exit program. */ return 0;}/***************************************************************************/