Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice:

Slides:



Advertisements
Similar presentations
C++ Introduction.
Advertisements

Module 6: Introduction to C Language ITEI102 Introduction to Programming Structure of C++ Program - Programming Terminologies - Microsoft Visual Studio.
Introduction to Programming Lecture 2. Today’s Lecture Software Categories Software Categories System Software System Software Application Software Application.
Systems Software.
COSC 120 Computer Programming
Three types of computer languages
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
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.
Introduction to C Topics Compilation Using the gcc Compiler
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Activity 1 - WBs 5 mins Go online and spend a moment trying to find out the difference between: HIGH LEVEL programming languages and LOW LEVEL programming.
Introduction to C/C++ Programming This lecture has major focus on programming, compilation.
Programming In C++ Spring Semester 2013 Programming In C++, Lecture 1.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Why Program? Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer.
Chapter Introduction to Computers and Programming 1.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
“C” Programming Language What is language ? Language is medium of communication. If two persons want to communicate with each other, they have to use.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
History of C and C++ C++ evolved from C ANSI C C++ “spruces up” C
C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Computer Engineering 1 nd Semester Dr. Rabie A. Ramadan 2.
Creating your first C++ program
Programming With C.
Introduction to C++ Programming Language
Evolution and History of Programming Languages. Machine languages Assembly languages Higher-level languages To build programs, people use languages that.
Evolution and History of Programming Languages. Software Programming Language.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 1 February 8, 2005.
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.
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.
1 Programming in C Hello World! Soon I will control the world! Soon I will control the world!
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
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.
Introduction to C CMSC 104, Section 4 Richard Chang 1.
CMSC 104, Lecture 111 Introduction to C Topics l Compilation l Using the gcc Compiler l The Anatomy of a C Program l 104 C Programming Standards and Indentation.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
CS-303 Introduction to Programming
Programming Fundamentals Lecture No. 2. Course Objectives Objectives of this course are three fold 1. To appreciate the need for a programming language.
Anatomy of the simplest C Program Sen Zhang SUNY Oneonta Oneonta, NEW YORK © 2004
The Development Process Compilation. Compilation - Dr. Craig A. Struble 2 Programming Process Problem Solving Phase We will spend significant time on.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
Introduction to C Programming Language. History of C  C was evolved by Dennis Ritchie at AT&T Bell Laboratories in early of 1970s  Successor of: ALGOL.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
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.
Introduction to C Programming
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Chapter 1: Introduction to Computers and Programming.
L071 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program Reading Sections
12/06/ :04:41 CSC Alliance — 1 Kimera Richard Phone: INSTITUTE OF COMPUTER SCIENCE DEPARTMENT.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 1.
1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail.
Introduction to C Topics Compilation Using the gcc Compiler
BASIC PROGRAMMING C SCP1103 (02)
UMBC CMSC 104 – Section 01, Fall 2016
Chapter 1: Introduction to computers and C++ Programming
BASIC PROGRAMMING C SCP1103 (02)
Instructor: Chien-Ho Ko
Microprocessor and Assembly Language
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.
Intro to Programming Week # 1 Hardware / Software Lecture # 2
Computer Engineering 1nd Semester
Introduction to C Topics Compilation Using the gcc Compiler
Introduction to C Topics Compilation Using the gcc Compiler
Creating your first C program
Programs written in C and C++ can run on many different computers
Introduction to C Topics Compilation Using the gcc Compiler
Presentation transcript:

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why. --unknown

Once a new technology starts rolling, if you're not part of the steamroller, you're part of the road. --Stewart Brand

Nabil Ur Rehman BICSE 3 Zeeshan Ahmad BICSE 3 Jahanzeb Maqbool BIT9-A Bibrak Qamar BIT9-A Aqsa Khalid BICSE5A

Introduction to C Programming Lecture 2

Today’s Lecture Software Categories Software Categories System Software System Software Application Software Application Software Introduction to ‘C’ Language Introduction to ‘C’ Language History History Evolution Evolution Justification Justification Development Environment of ‘C’ Development Environment of ‘C’

There are two main categories of software System software System software Application Software Application Software

Evolution of programming languages The lack of portability between different computers led to the development of high- level languages—so called because they permitted a programmer to ignore many low-level details of the computer's hardware The lack of portability between different computers led to the development of high- level languages—so called because they permitted a programmer to ignore many low-level details of the computer's hardware Details of procedural, non-procedural will follow in the lectures Details of procedural, non-procedural will follow in the lectures

How people used to program Machine Language….. Damn! It was difficult Machine Language….. Damn! It was difficult Assembly Language…. Remember ADD? Assembly Language…. Remember ADD? –Required too much user involvement –To much to remember –Less semantic C Language C Language –B Language.. Bell Labs –Improved to C Language –Is a compiled language

ANSI C ANSI C

Tools of the trade Editor Editor Interpreter and Compilers Interpreter and Compilers Debuggers Debuggers

Integrated Development Environment (IDE) It contains Editor Editor Compilers Compilers Debugger Debugger Linkers Linkers Loaders Loaders

Preprocessor program processes the code. Loader puts program in memory. CPU takes each instruction and executes it, possibly storing new data values as the program executes. Compiler creates object code and stores it on disk. Linker links the object code with the libraries Loader Primary Memory Compiler Editor Preprocessor Linker Primary Memory Disk CPU Disk Program is created in the editor and stored on disk.

#include #include main ( ) { cout << “ Welcome to SEECS “; }

Variable Variable X

Variable Pic of the memory Pic of the memory name of the variable

Variable Variable starts with 1.Character 2.Underscore _ (Not Recommended)

Variable Small post box Small post box X

Variable Variable is the name of a location in the memory e.g. x= 2; e.g. x= 2;

Variable In a program a variable has: 1. Name 2. Type 3. Size 4. Value

Assignment Operator = x = 2 X 2

Assignment Operator L.H.S = R.H.S. X+ 3 = y + 4 Wrong Z = x +4 x +4 = Z Wrong

X = 10 ; X = 30 ; X 10 X 30

X = X + 1; X = X 11

Data type int i ; //Declaration line int i ; //Declaration line i

Writing C program

Compiler converts human readable language to a language which is understandable by the operating system/hardware Examples of C/C++ compilers of today: Visual C++ GCC/G++ DJGPP (open source for windows like GCC) Borland C Turbo (obsolete and not recommended)

3 Stages of Compilation Stage 1: Preprocessing – Performed by a program called the preprocessor – Modifies the source code (in RAM) according to preprocessor directives (preprocessor commands) embedded in the source code –Strips comments and white space from the code –The source code as stored on disk is not modified.

3 Stages of Compilation (con’t) Stage 2: Compilation oPerformed by a program called the compiler oTranslates the preprocessor-modified source code into object code (machine code) oChecks for syntax errors and warnings oSaves the object code to a disk file, if instructed to do so (we will not do this). o If any compiler errors are received, no object code file will be generated. o An object code file will be generated if only warnings, not errors, are received.

Object code: It is machine language code containing various calls specific to operating system… e.g the object code written by compiler is not only hardware dependent but also operating system dependent. It is machine language code containing various calls specific to operating system… e.g the object code written by compiler is not only hardware dependent but also operating system dependent. So if you have linux and windows both operating systems then object file of compiled by one Operating System (OS) will not get executed on the other OS So if you have linux and windows both operating systems then object file of compiled by one Operating System (OS) will not get executed on the other OS

3 Stages of Compilation (con’t) Stage 3: Linking oCombines the program object code with other object code to produce the executable file. oThe other object code can come from the Run- Time Library, other libraries, or object files that you have created. oSaves the executable code to a disk file. On the Linux system, that file is called a.out. o If any linker errors are received, no executable file will be generated.

Program Development Using gcc Source File pgm.c Program Object Code File pgm.o Executable File a.out Preprocessor Modified Source Code in RAM Compiler Linker Other Object Code Files (if any) Editor

#include //This is pre-processor directive void main ( ) //this tells the starting point of your program { int x ; int y ; int z ; x = 10 ; y = 20 ; z = x + y ; cout << " x = " ; //print the text on monitor cout << x ; cout << " y = " ; cout << y ; cout << " z =x + y = " ; cout << z ; }

int x, y, z ; int x; int y; int z ;