Chapter 5: Preparing C Programs

Slides:



Advertisements
Similar presentations
Chapter 11 Introduction to Programming in C
Advertisements

Etter/Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 1 Engineering Problem Solving.
Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
C-Language : Basic Concepts 2013, Fall Pusan National University Ki-Joune Li.
Chapter 1: An Overview of Computers and Programming Languages
C Programming Day 1 based upon Practical C Programming by Steve Oualline CS550 Operating Systems.
Chapter 6: Algorithmic Problem Solving 1 Chapter 6 Algorithmic Problem Solving.
CS211 Data Structures Sami Rollins Fall 2004.
Chapter 16 Programming and Languages: Telling the Computer What to Do.
1 ICS103 Programming in C Lecture 2: Introduction to C (1)
Guide To UNIX Using Linux Third Edition
CS 101 Problem Solving and Structured Programming in C Sami Rollins Spring 2003.
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
Moving To Code 3 More on the Problem-Solving Process §The final step in the problem-solving process is to evaluate and modify (if necessary) the program.
Introduction to C. A Brief History Created by Dennis Ritchie at AT&T Labs in 1972 Originally created to design and support the Unix operating system.
Chapter 1 Introduction to Programming. Computer Hardware CPU Memory –Main or primary –Secondary or auxiliary Input device(s) Output device(s)
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages Updated by: Dr\Ali-Alnajjar.
Programming a computer. What does programming a computer mean ? Programming a computer: Since a computer can only execute machine instructions (encoded.
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
Introduction to C Programming. A Brief History u Created by Dennis Ritchie at AT&T Labs in 1972 u Originally created to design and support the Unix operating.
Introduction to Computer & C Computers Computers are programmable machines capable of performing calculations Examples of special-purpose computers are.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Computer Science 101 Introduction to Programming.
Chapter 5: Preparing Java Programs 1 Chapter 5 Preparing Java Programs.
Programming With C.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
1 Programming in C Hello World! Soon I will control the world! Soon I will control the world!
C Language: Introduction
J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second Edition D.S. Malik D.S. Malik.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
How to Program? -- Part 1 Part 1: Problem Solving –Analyze a problem –Decide what steps need to be taken to solve it. –Take into consideration any special.
Programming Languages
First Compilation Rudra Dutta CSC Spring 2007, Section 001.
Skill Area 311 Part B. Lecture Overview Assembly Code Assembler Format of Assembly Code Advantages Assembly Code Disadvantages Assembly Code High-Level.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Chapter 6 Testing and running a solution. Errors X Three types Syntax Logic Run-time.
Software Engineering Algorithms, Compilers, & Lifecycle.
1 THE C COMPILATION STEPS. Najib Nadi Computing Sciences VU C Compilation Steps C Source Code FILE prog.c OPTION C Source Code C Source Code C Source.
KYC - Know your compiler Introduction to GCC
Makefiles CSSE 332 Operating Systems
Why don’t programmers have to program in machine code?
Introduction to Computers and C++ Programming
Chapter 1: An Overview of Computers and Programming Languages
Chapter 5- Assembling , Linking, and Executing Programs
C Programming Hardik H. Maheta.
Chapter 1: An Overview of Computers and Programming Languages
What's a Computer? Monitor Disk Main mouse Memory Keyboard Network
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
ICS103 Programming in C Lecture 3: Introduction to C (2)
Introduction to C Topics Compilation Using the gcc Compiler
Lecture2.
TRANSLATORS AND IDEs Key Revision Points.
Assembler, Compiler, Interpreter
and Executing Programs
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Chapter 11 Introduction to Programming in C
Hands-On Ethical Hacking and Network Defense
Chapter 1: An Overview of Computers and Programming Languages
1) C program development 2) Selection structure
Chapter 11 Introduction to Programming in C
Creating your first C program
Chapter 1: An Overview of Computers and Programming Languages
Lecture3.
Assembler, Compiler, Interpreter
Homework Applied for cs240? (If not, keep at it!) 8/10 Done with HW1?
Chapter 11 Introduction to Programming in C
PROGRAMMING FUNDAMENTALS Lecture # 03. Programming Language A Programming language used to write computer programs. Its mean of communication between.
Introduction to C Programming
An Introduction to Programming with C++ Fifth Edition
CHAPTER 6 Testing and Debugging.
Presentation transcript:

Chapter 5: Preparing C Programs

Program development Understanding the problem EDIT Writing an algorithm Converting to code COMPILE RUN errors Result Verifying the algorithm Chapter 5 Program development

Program development pico prog.c cc prog.c a.out Source code EDIT COMPILE RUN errors Result Source code pico prog.c cc prog.c a.out Chapter 5 Program development

High-level languages Machine language: computer’s native language. Add two numbers: 00100111 1010 0101 Assembly language: uses mnemonics. Add two numbers: ADD R1 R2 An assembly code needs to be translated to machine code. Chapter 5 High-level languages

High-level languages High-level programming languages: bridging the gap between machine language and natural languages. Examples: COBOL, Fortran, Algol, C Add two numbers (in C): Z = A + B; Compilation: translation to machine code. Chapter 5 High-level languages

A C program A sample C program /* A simple C program to read a number & compute and display its square by using the multiplication (*) operator. */ #include <stdio.h> main () /* a C program always has a main function */ { int n; /* this declares an integer variable 'n' */ printf ("\nEnter the number to be squared: "); scanf ("%d", &n); printf ("Using the * operator, the square of %d is %d.\n\n", n, n*n); } Chapter 5 A C program

Compilation in C Use the cc or gcc compiler: cc prog.c Produces executable file a.out if no errors To specify name of executable file, use -o option: cc -o prog prog.c Name of executable file becomes ‘prog’. Chapter 5 Compilation in C

Errors Compilation errors: occur during compilation. Reason: syntax errors. Easy to rectify. Run-time errors: occur during execution. Reasons: logic errors, data errors, computation errors. Harder to rectify. Chapter 5 Errors

Homework Try exercises in chapter 5. Chapter 5 Homework