History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between 1970-1980 - Ada.

Slides:



Advertisements
Similar presentations
11-2 Identify the parts of the “main” function, which include Preprocessor Directives main function header main function body which includes Declaration.
Advertisements

Lecture 2 Introduction to C Programming
Introduction to C Programming
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
C Programming Language 4 Developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories 4 Used to rewrite the UNIX operating system 4 Widely used on UNIX.
CS1061 C Programming Lecture 2: A Few Simple Programs A. O’Riordan, 2004.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
Introduction to C Programming Overview of C Hello World program Unix environment C programming basics.
1 ICS103 Programming in C Lecture 2: Introduction to C (1)
Guide To UNIX Using Linux Third Edition
Introduction to C Programming
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
C programming Language and Data Structure For DIT Students.
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.
Functions in C. Function Terminology Identifier scope Function declaration, definition, and use Parameters and arguments Parameter order, number, and.
Computer Science 210 Computer Organization Introduction to C.
“C” Programming Language CIS 218. Description C is a procedural languages designed to provide lowlevel access to computer system resources, provide language.
Introduction to C++ - How C++ Evolved Most popular languages currently: COBOL, Fortran, C, C++, Java (script) C was developed in 1970s at AT&T (Richie)
Gator Engineering 1 Chapter 2 C Fundamentals Copyright © 2008 W. W. Norton & Company. All rights reserved.
Programming With C.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Structure of a C program Preprocessor directive (header file) Program statement } Preprocessor directive Global variable declaration Comments Local variable.
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.
C programming language was developed in the seventies by a group of at the Bell Telephone lab. The C language was the outline of two earlier languages.
Khalid Rasheed Shaikh Computer Programming Theory 1.
Agenda Computer Languages How to Write a Simple C Program
Minimal standard C program int main(void) { return 0 ; }
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Operating System Discussion Section. The Basics of C Reference: Lecture note 2 and 3 notes.html.
Introduction Chapter 1 1/22/16. Check zyBooks Completion Click on the boxes for each section.
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.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Chapter 1 slides1 What is C? A high-level language that is extremely useful for engineering computations. A computer language that has endured for almost.
Introduction to C Programming I Subject: T0016 – ALGORITHM AND PROGRAMMING Year: 2013.
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.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
Lecture2.
Computer Science 210 Computer Organization
CSC201: Computer Programming
Introduction to C Language
Chapter 2 - Introduction to C Programming
C Programming Hardik H. Maheta.
Chapter 2, Part I Introduction to C Programming
C Language By Sra Sontisirikit
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.
History of ‘C’ Root of the morden language is ALGOL It’s first
Overview of C.
Getting Started with C.
Introduction to C Programming Language
Chapter 2 - Introduction to C Programming
Choice of Programming Language
Welcome In The World Of ‘C’.  TEXT BOOK: Programming in ANSI ‘C By: E Balagurusamy. TMH  Reference Books: 1) The ‘C Programming Language By: Kernighan.
Computer Science 210 Computer Organization
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Introduction to C Topics Compilation Using the gcc Compiler
Chapter 2 - Introduction to C Programming
Lecture3.
C programming Language
Introduction to C Topics Compilation Using the gcc Compiler
Chapter 2 - Introduction to C Programming
An Overview of C.
Introduction to C Programming
Presentation transcript:

History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada

History of C 1967 – BCPL –By Martin Richards –For writing OS and compilers 1970 – B –Used to write UNIX OS for DEC PDP – C –By Dennis Ritchie –Used to write UNIX OS for DEC PDP-11 –Now almost all OS are written in C/C++

History of C C became popular after a book written by Ritchie and Kernighan – ‘The C Programming Language’ Many variations came up for different platforms ANSI (American National Standards Institute) approved a standard in 1989

Programming Tools Compiler Standard Library IDE Help files & documentations

Compilers What does it do? –Parse the code –Tokenize –Match syntax –Find Errors –Prepare object code

Standard Library What does it do? –Provide implementations of some basic and important functions –Usually these functions are very efficient –Programmers should use library functions to improve performance and portability

IDE - Integrated Development Environment Helps to Write –Use different color to highlight different type of code –Sometimes shows hints Helps to Compile –Set environment variables –Linking with libraries

IDE - Integrated Development Environment Helps to Debug –Execute step by step –Use breaks –Watch the values of variables Helps to Run

Help Files and Documentation Provide details about –Syntax –Keywords –Library functions –Examples –Etc.

C Files Source File –.c –Contains the code –A program may use multiple source files Object File –.obj –Compiled source file

C Files Header File –.h –Contains codes of library functions –We can also write header files Library File –.lib –Compiled library function

C Files Executable File –.exe –Final program Backup File –.bak Other Files

Lifecycle of a C Program Source File User defined Header File Standard Header File Object File Compile Library File Compile Executable File Link

A first look at C # include void main(void) { printf(“First C Program”); }

A first look at C # include void main(void) { printf(“First C Program”); } # include Must be written first Means we want to include or use the functions defined in the header

A first look at C # include void main(void) { printf(“First C Program”); } # include # symbol indicates a preprocessor It means it has to be done before compilation

A first look at C # include void main(void) { printf(“First C Program”); } Name of the header file You must know which header you need Use help and documentation to find out

A first look at C # include void main(void) { printf(“First C Program”); } Enclosed in (header in default place) May be enclosed in “ ” (header is in the same folder as the source)

A first look at C # include void main (void) { printf(“First C Program”); } main Every C program must have a ‘main’ function Program starts from the 1st line in ‘main’

A first look at C # include void main (void) { printf(“First C Program”); } main Functions has parameters enclosed in ( ) Functions may return values

A first look at C # include void main(void) { printf(“First C Program”); } { } The curly braces are like containers The code between two braces are called a block

A first look at C # include void main(void) { printf(“First C Program”); } { } Missing either brace will generate compile error –“Compound Statement missing”

A first look at C # include void main(void) { printf (“First C Program”); } printf A function given in stdio.h Prints the text given as the parameter

A first look at C # include void main(void) { printf(“First C Program”) ; } “ ; ” (semicolon) Every C statement must end with a ; Otherwise compiler will generate an error –“Statement Missing”

A first look at C # include void main(void) { printf(“First C Program”); } Keywords The texts in White are keywords These are words that has special meanings for C

Another Example /* My second C Program*/ # include <stdio.h> void main(void) { printf(“My Second C Program\n”); } //end of code \n // main function

Another Example /* My second C Program*/ Enclosed within /* and */ This is a multi-line Comment It is not part of the code Compiler ignores it Used for helping the programmer to understand the code better

Another Example // main function This is a single-line Comment

Another Example \n This is an escape sequence ‘\’ is escape character It indicates that printf should do something different with the character that follows the \

Another Example \n \n = new line (like an ‘enter’ key) \t = tab \a = alert (the PC speaker gives a beep) \\ = \(to print \) \” = “(to print “ or ” )

Yet Another Example # include void main(void) { int a;// declaring a variable a = 10;// assign a value printf(“The Value of a is = %d”, a); }

Yet Another Example int a; ‘int’ is a keyword It means that the variable declared here is an integer So ‘int’ defines the data type C has many data types

Yet Another Example int a; ‘a’ is the variable name The statement creates/defines a new variable named ‘a’ Creating a variable means reserving a memory location for it The size of the memory needed depends on the data type

Yet Another Example a = 10; This is an assignment statement This means the value ‘10’ is written in the memory location reserved for ‘a’ Before using a variable or assigning a value, we have to define it first –Or a compile error “Unknown identifier”/ “Undefined Symbol” will occur

Yet Another Example printf(“The Value of a is = %d”, a); This is the way a variable’s value can be outputted The first parameter is format control string. –The format and layout of output text is defined here

Yet Another Example printf(“The Value of a is = %d”, a); “%d” is a conversion specifier It tells the printf function that it has to print the value of an integer variable here

Yet Another Example printf(“The Value of a is = %d”, a); The second parameter tells the printf function the value that should be printed in place of the “%d”

Today’s Last Example # include void main(void) { int a;// declaring a variable printf(“Please enter value of a:”); scanf(“%d”, &a); // inputs a value printf(“\nThe Value of a is = %d”, a); }

Today’s Last Example scanf(“%d”, &a); scanf is another function given in stdio.h It is used to take inputs from the user Syntax is similar to printf

Today’s Last Example scanf(“%d”, &a); NOTE: –Here the variable name is preceded by ‘&’ symbol. –It indicates the address of the memory location that was reserved for ‘a’ –Omitting the symbol will cause wrong results

Looking Back We learned about the history of C We learned what tools is needed for software development We learned the important files associated with C

Looking Back Every C Code begins with the #include directive Every C Program must contain one and only one function named ‘main’ A program should have comments to make it easy to understand

Looking Back Variables must be defined before they can be used printf is used to output scanf for input We learned about escape sequence We also learned about conversion specifier

Looking Back We learned about a few compile errors –Statement missing –Compound Statement missing –Unknown identifier