C LANGUAGE Characteristics of C · Small size

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Pointers.
Question Bank. Explain the syntax of if else statement? Define Union Define global and local variables with example Concept of recursion with example.
Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
Programming and Data Structure
Programming Languages and Paradigms The C Programming Language.
1 Chapter 10 Strings and Pointers. 2 Introduction  String Constant  Example: printf(“Hello”); “Hello” : a string constant oA string constant is a series.
Lecture 20 Arrays and Strings
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
Pointers in C Rohit Khokher
Pointer applications. Arrays and pointers Name of an array is a pointer constant to the first element whose value cannot be changed Address and name refer.
Memory allocation CSE 2451 Matt Boggus. sizeof The sizeof unary operator will return the number of bytes reserved for a variable or data type. Determine:
Chapter 10.
C Programming Basics Lecture 5 Engineering H192 Winter 2005 Lecture 05
1 CSE1301 Computer Programming: Lecture 35 Revision.
C Language Summary HTML version. I/O Data Types Expressions Functions Loops and Decisions Preprocessor Statements.
Topic R3 – Review for the Final Exam. CISC 105 – Review for the Final Exam Exam Date & Time and Exam Format The final exam is 120-minutes, closed- book,
1 Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation –The new operator –The delete operator –Dynamic.
Guide To UNIX Using Linux Third Edition
CSE1301 Computer Programming: Revision. Topics Type of questions What do you need to know? About the exam Exam technique Sample questions.
C FAQ’S Collected from the students who attended technical round in TCS recruitment.
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
LECTURE 4: INFORMATION REPRESENTATION (PART II) COMP26120: ALGORITHMS AND IMPERATIVE PROGRAMMING.
Stream Handling Streams - means flow of data to and from program variables. - We declare the variables in our C++ for holding data temporarily in the memory.
CECS 121 EXAM 1. /* C Programming for the Absolute Beginner */ // by Michael Vine #include main() { printf(“\nC you later\n”); system(“pause”); }
High-Level Programming Languages: C++
CIS Computer Programming Logic
DAT602 Database Application Development Lecture 5 JAVA Review.
Gary MarsdenSlide 1University of Cape Town Principles of programming language design Gary Marsden Semester 2 – 2001.
By Sidhant Garg.  C was developed between by Dennis Ritchie at Bell Laboratories for use with the Unix Operating System.  Unlike previously.
Review C Language Features –control flow –C operators –program structure –data types –I/O and files Problem Solving Abilities.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 12: Pointers continued, C strings.
Dynamic Memory Allocation The process of allocating memory at run time is known as dynamic memory allocation. C does not Inherently have this facility,
Pointer. What is pointer ? A Pointer is nothing but a variable that contains an address which is a location of another variable in memory. If one variable.
Prepared By Ms.R.K.Dharme Head Computer Department.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
CS Midterm Study Guide Fall General topics Definitions and rules Technical names of things Syntax of C++ constructs Meaning of C++ constructs.
Copyright © Curt Hill Structured Data What this course is about.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process.
Introduction to C For the participants of Practical Course „Scientific Computing and Visualization“
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics Lecture 5.
CECS 130 EXAM 1. To declare a constant (read only) value: const int x = 20; const float PI = 3.14; Can we do this? const int x;
Pointers *, &, array similarities, functions, sizeof.
Computer Organization and Design Pointers, Arrays and Strings in C Montek Singh Sep 18, 2015 Lab 5 supplement.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 C Basics Tarek Abdelzaher and Vikram Adve.
STL CSSE 250 Susan Reeder. What is the STL? Standard Template Library Standard C++ Library is an extensible framework which contains components for Language.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
EEL 3801 C++ as an Enhancement of C. EEL 3801 – Lotzi Bölöni Comments  Can be done with // at the start of the commented line.  The end-of-line terminates.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
Lecturer: Nguyen Thi Hien Software Engineering Department Home page: hienngong.wordpress.com Chapter 2: Language C++
C Language Elements: Preprocessor Directives Commands that give instructions to the C preprocessor Modifies text of a C program before compilation Two.
MORE POINTERS Plus: Memory Allocation Heap versus Stack.
Sections Basic Data Structures. 1.5 Data Structures The way you view and structure the data that your programs manipulate greatly influences your.
Outline Review Functions Pointers –Function calls –Array Pointers –Pointer Arrays Data Structures and dynamic Memory Function Pointers –quicksort example.
Lecture 3 Translation.
Introduction to Computers Computer Generations
5.13 Recursion Recursive functions Functions that call themselves
Programming Languages and Paradigms
C Language By Sra Sontisirikit
Learning C Language.
C Short Overview Lembit Jürimägi.
Programming Paradigms
C Basics.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Introduction to Data Structure
Chapter 9: Pointers and String
Programming Languages and Paradigms
C Language B. DHIVYA 17PCA140 II MCA.
SPL – PS1 Introduction to C++.
Presentation transcript:

C LANGUAGE Characteristics of C · Small size · Extensive use of function calls · Loose typing -- unlike PASCAL · Structured language ·Pointer implementation - extensive use of pointers for memory, array, structures and functions.

C Program Structure Preprocessor Commands Type definitions Function prototypes -- declare function types and variables passed to function Variables Functions

Creating, Compiling and Running Your Program Use any ordinary editor with which you are familiar to create the file The filename must by convention end ``.c'' (full stop, lower case c), e.g. myprog.c

The C Compilation Model Source code Preprocessor Compiler Assembly code Assembler libraries Object code Link Editor Executable code

The Preprocessor The Preprocessor accepts source code as input and is responsible for removing comments interpreting special preprocessor directives denoted by #. C Compiler The C compiler translates source to assembly code Assembler The assembler creates object code

Variables C type Size (byte) Unsigned char 1 Short int 2 Unsigned short int 2 (long) int 4 float 4 double 8

Arithmetic Operations Increment & Decrement operations Postfix and Prefix expressions example:- x++ is faster than x=x+1.

Order of Precedence () [ ] -> . * / % + - < <= >= > () [ ] -> . * / % + - < <= >= > == != & ^ && || ,

CONDITIONALS IF STATEMENT ? OPERATOR SWITCH STATEMENT break and continue C provides two commands to control how we loop:   ·         break -- exit form loop or switch. continue -- skip 1 iteration of loop

FUNCTIONS { localvariables functioncode } VOID FUNCTIONS returntype fn_name(1, parameterdef2,…) { localvariables functioncode } VOID FUNCTIONS

Structures Collection of different datatypes. A structure is a user-defined data type. A structure is a collection of one or more variables, possibly of different types, grouped together under a single name Eg: struct student { int rollno; char name[10]; float marks; } s ;

UNIONS A union is a variable which may hold (at different times) objects of different sizes and types . union number { short shortnumber; long longnumber; double float number; }

* POINTERS C uses pointers a lot. Why?: ·         It is the only way to express some computations. ·         It produces compact and efficient code. ·         It provides a very powerful tool.   What is a Pointer? A pointer is a variable which contains the address in memory of another variable .

Dynamic Memory Allocation Dynamic allocation is a pretty unique feature to C . It enables us to create data types and structures of any size and length to suit our programs need within the program. Malloc Calloc Realloc  

FILES Files are the most common form of a stream Open a file: FILE *fopen(char *name, char *mode) fopen returns a pointer to a FILE. *name ?? *mode ?? Reading and writing files The functions fprintf and fscanf a commonly used to access files.   int fprintf(FILE *stream, char *format, args..) int fscanf(FILE *stream, char *format, args..)  

Basic String Handling Functions strcmp strcat strcpy strlen strerror strcasecmp

DATA STRUCTURES Definition of data structures • Many algorithms require that we use a proper representation of data to achieve efficiency. • This representation and the operations that are allowed for it are called data structures. • Each data structure allows insertion, access, deletion etc.

Why do we need data structures? • Data structures allow us to achieve an important goal: component reuse • Once each data structure has been implemented once, it can be used over and over again in various applications.

Common data structures are • Stacks • Queues Lists Trees Graphs Tables

SORTING TECHNIQUES Bubble sort Quick sort Insertion sort Selection sort Heap sort