Programming Fundamentals Lecture #3 Overview of Computer Programming

Slides:



Advertisements
Similar presentations
Module 6: Introduction to C Language ITEI102 Introduction to Programming Structure of C++ Program - Programming Terminologies - Microsoft Visual Studio.
Advertisements

Lecture 2 Introduction to C Programming
Introduction to C Programming
 2005 Pearson Education, Inc. All rights reserved Introduction.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
 C++ programming facilitates a disciplined approach to program design. ◦ If you learn the correct way, you will be spared a lot of work and frustration.
Introduction to C Programming
Introduction Kingdom of Saudi Arabia Shaqra University
CS1061 C Programming Lecture 2: A Few Simple Programs A. O’Riordan, 2004.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
 2003 Prentice Hall, Inc. All rights reserved. 1 Machine Languages, Assembly Languages, and High-level Languages Three types of computer languages 1.Machine.
Introduction to C Programming
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
CHAPTER 1: INTORDUCTION TO C LANGUAGE
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
Using C Programming Language.  The programs that run on a computer are referred to as software.  You’ll learn key programming methodology that are enhancing.
Using C Programming Language.  The programs that run on a computer are referred to as software.  You’ll learn key programming methodology that are enhancing.
History of C and C++ C++ evolved from C ANSI C C++ “spruces up” C
Programming With C.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 1 February 8, 2005.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Introduction to C Programming Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010 Fall.
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
COMPUTER PROGRAMMING. A Typical C++ Environment Phases of C++ Programs: 1- Edit 2- Preprocess 3- Compile 4- Link 5- Load 6- Execute Loader Primary Memory.
CHAPTER 2 PART #1 C++ PROGRAM STRUCTURE 1 st semester H 1 King Saud University College of Applied studies and Community Service Csc 1101 By:
1 Programming in C Hello World! Soon I will control the world! Soon I will control the world!
INTRODUCTION Kingdom of Saudi Arabia Princess Nora bint Abdul Rahman University College of Computer Since and Information System CS240.
Chapter 2 part #1 C++ Program Structure
CHAPTER 1: INTRODUCTION C++ Programming. CS 241 Course URL: Text Book: C++ How to Program, DETITEL & DEITEL, eighth Edition.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 1 – Introduction to C.
An overview of C Language. Overview of C C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT &T's.
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
BIL 104E Introduction to Scientific and Engineering Computing Lecture 1.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Introduction to C Topics Compilation Using the gcc Compiler
CHAPTER 2 PART #1 C++ PROGRAM STRUCTURE
Chapter 1: Introduction to computers and C++ Programming
Chapter 2 Introduction to C++ Programming
CSC201: Computer Programming
Introduction to C Language
CS-103 COMPUTER PROGRAMMING
Chapter 2 - Introduction to C Programming
Chapter 2, Part I Introduction to C Programming
Chapter 2 part #1 C++ Program Structure
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.
Beginning C++ Programming
Introduction to C Topics Compilation Using the gcc Compiler
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Introduction to C++ Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Introduction to C++ Programming
C programming Language
Introduction to Computer Programming
Programs written in C and C++ can run on many different computers
Capitolo 1 – Introduction C++ Programming
Chapter 2 - Introduction to C Programming
An Overview of C.
Computer Programming-1 CSC 111
Chapter 1 Introduction to Programming
Introduction to C Topics Compilation Using the gcc Compiler
Introduction to C Programming
Chapter 2 part #1 C++ Program Structure
Presentation transcript:

Programming Fundamentals Lecture #3 Overview of Computer Programming Junaid Hassan Lecturer CS & IT Department UOS MBDIN junaidte14@gmail.com

Assignment What do you know about history of C Programming Language? Consult course book (C How to Program by Paul Dietel and Harvey Dietel, 6th or 7th Edition) Do some research on internet Discuss your concepts with your classmates Submit your assignment in hand written pages There may be a viva from your submitted assignment, so avoid copying other’s assignment

C Standard Library C programs consist of modules / pieces called as functions C standard library is a library having pre-built functions. So if there’s an already built-in function available in C standard library then programmers prefer to use those functions instead of creationg their own functions. This approcah of using already available functions is called software reuseability approach

C Programming Building Blocks When programming in C use following building blocks: C standard library functions (or Library Functions) Functions you create yourself (or Custom Functions) Functions other people have created and made available to you

Functions you create yourself (Custom Functions) Advantages: you know your code exactly how it works You can examin that code easily Disadvantages: Time consuming process Reinventing the wheel Performance issues Security issues Compatibility issues

C Standard Library Functions (Library Functions) Advantages: No security issues No performance issues No compatibility issues Your code will be portable to all devices which uses standard C implementations Code will be error free Time is saved Disadvantages: You will have to learn how to use that function

Typical C Program Development Environment C systems consist of 3 main parts: Program development environment C programming language C standard library C Program Development Environment means which phases are involved in a typical C Program Development.

Typical C Program Development Environment C program typically goes through six phases: Phase 1: Creating a program (editor programs are used to create code files. These code files are stored in our computer hard drive. C program files are ended with the extension .c) Phase 2: Preprocessing (certain manipulations are performed befor compilation e.g inclusion of external files in the main program file) Phase 3: Compiling a C program (compiler translates C program/code to machine-language code. machine-language code also called as object code) Phase 4: Linking (Linker links the object code with the libraries, creates an executable file and stores it on disk) Phase 5: Loading (Loader puts the program in memory) Phase 6: Execution (CPU takes each instruction and executes it)

Typical C Program Development Environment C program typically goes through six phases:

Typical C Program Development Environment C program typically goes through six phases:

Typical C Program Development Environment Problems that may occure at execution time: Code Errors (in case of errors we go back to the editor phase, fix that error and then execute the program again) Two type of errors can occure in a program: Fatal Errors (which causes the program to terminate immediately without proceeding further e.g division by zero). Fatal errors are also called as run time errors or execution time errors. None Fatal Errors (These errors allow programs to execute completely but produces incorrect results)

A Simple C Program Prints a line of text:

A Simple C Program Lines starting with /* and ending with */ are called comments (multi line comments) Comments are used to describe why we added this code line thus improving program readability Comments are not executed when we run our program Comments are ignored by compilers Comments help other people to understand your program Lines starting with // are also called comments (single line comment) We don’t need to end single line comments Lines starting with # are processed by preprocessor before the program is compiled e.g #include <stdio.h> tells the preprocessor to include standard input output header file in our program Why? Because we want to use functions available in that standard library. In our program we used a function printf() which is actually defined stdio.h standard library file.

A Simple C Program int main(void){ ..... } is part of every C programs. Parentheses show that it’s a function. A function is building block which takes an input, processes that input and return an output. This main function is executed at first. Every C program must have atleast one main function. Int means that this function return an integer value. void means that this function does not accept any input { left brace starts the body of the function where } right brace ends the body of the function printf(“”Welcome to C!\n”); instructs the computer to perform an action i.e to print on the screen the string of characters inside quotation marks and \n says that after printing that string move to the next line This entire line printf(“”Welcome to C!\n”); is called a statement.

A Simple C Program Every statement must end with a semicolon (also called as statement terminator) The backslash (\) is called an escape character. Every escape character when combined with character after it, form an escape sequesnce. Every escape sequence has a special meaning e.g \n when appears inside a string output by printf means newline. It moves the cursor position to the next line

A Simple C Program return 0; is included at the end of each main function Keyword return is used to exit a function