Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
COE 108- C Programming
Course Outline
Lecture#1
1
2
Description
• The objective of this course is to understand the conceptsof structural programming design.
• Firstly, basic program codes will be copied and examinedas an introduction.
• Then, basic data structures will be introduced.
• The most important part of the course is to understandthe structure of any given problem and design analgorithm to implement the solution.
• C programming language will be used to implement anycode in structural design.
3
Textbooks
• "C How to Program", 7th edition, by Deitel & Deitel(published by Pearson Education).
4
Outline
• Lecture#1: Course Introduction
• Lecture#2: Introduction to C Programming
• Lecture#3: Data Types and Memory Concepts
• Lecture#4: Arithmetic Operators and Decision Making
• Lecture#5: Structured Program Development in C
• Lecture#6: Structured Program Development in C Part#2
• MidtermExam
• Lecture#7: C Program Control Part I
• Lecture#8: C Program Control Part II
• Quiz#1
• Lecture#9: C Functions
• Lecture#10: Arrays
• Lecture#11: Arrays Part II
• Project Control
5
Grading Criteria
• Quizzes (1) 10%
• Project Assignment (1) 10%
• Midterm Exam 30%
• Final Exam 50%
6
Course Homepage
• http://aytugonan.cbu.edu.tr/COE108_index.html
Definition of Algorithms
• Algorithms are “methods for solving problems which aresuited for computed implementation.” [Sedgewick]
• An algorithm is “a finite sequence of instructions, each ofwhich has a clear meaning and can be performed with a finiteamount of effort in a finite length of time.” [Aho, Hopcroft, &Ulman]
• “Algorithmics [defined as the study of algorithms -- A.L.] ismore than a branch of computer science. It is the core ofcomputer science, and, in all fairness, can be said to berelevant to most of science, business, and technology.”[David Harel, “Algorithmics: The Spirit of Computing”]
7
What is an Algorithm ?
An algorithm is a finite, clearly specified sequence ofinstructions to be followed to solve a problem or compute afunction
An algorithm generally• takes some input• carries out a number of effective instructions in a finite
amount of time• produces some output.
An effective instruction is an operation so basic that it ispossible to carry it out using pen and paper.
8
Properties of an Algorithm
• CorrectnessAlgorithm gives the right answer
• for all possible cases
• FinitenessAlgorithm stops in reasonable time
• produces an output
• EffectivenessInstructions are simple
• can be carried out by pen and paper
• DefinitenessInstructions are clear
• meaning is unique
9
Notion of an Algorithm
10
problem
algorithm
computerinput output
Algorithm Design
Programming the Algorithm
Expressing Algorithms
Algorithms can be expressed in • natural languages
-verbose and ambiguous-rarely used for complex or technical algorithms
• pseudocode, flowcharts-structured ways to express algorithms-avoid ambiguities in natural language statements-independent of a particular implementation language
• programming languages -intended for expressing algorithms in a form that can be executed by a computer-can be used to document algorithms
11
Example:Problem : Convert temperature Fahrenheit to Celsius Inputs to the algorithm:
Temperature in FahrenheitExpected output:
Temperature in Celsius
Natural Language:
Step1: StartStep 2: Read Temperature in FahrenheitStep 3: Calculate the result of conversion using the formula
C= 5/9*(F-32)Step 4: Print Temperature in Celsius: CStep5: End
12
Example:
Pseudocode:
Algorithm Convert_Fahrenheit_to_Celsius (F)
Input: Temperature value in Fahrenheit :F
Output: The value of temperature in Celsius : C
C ← 5/9*(F-32)return C
13
Common Flowchart Symbols
14
Example:
Problem: Convert temperature Fahrenheit to Celsius
START
READ F
C = 5/9 * (F - 32)
PRINT C
END
C Programming
• C is a general-purpose, procedural computerprogramming language developed in 1972 by DennisM. Ritchie at the Bell Telephone Laboratories todevelop the UNIX operating system.
• C is the most widely used computer language.
• The main features of C language include simple set ofkeywords and clean style.
• Many later languages have borrowed syntax/featuresdirectly or indirectly from C language.