“C” Programming Language CIS 218. Description C is a procedural languages designed to provide lowlevel access to computer system resources, provide language.

Slides:



Advertisements
Similar presentations
CSE 105 Structured Programming Language (C)
Advertisements

Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
Chapter 3: Beginning Problem Solving Concepts for the Computer Programming Computer Programming Skills /1436 Department of Computer Science.
Lecture 2 Introduction to C Programming
1 CS 201 Introduction to C (1) Debzani Deb. 2 Outline Overview of C General form of a C program C Language Elements.
Introduction to C Programming CE Lecture 1 Introduction to C.
Unix Continuum of Tools Do something once: use the command line Do something many times: –Use an alias –Use a shell script Do something that is complex.
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?
1 ICS103 Programming in C Lecture 2: Introduction to C (1)
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Guide To UNIX Using Linux Third Edition
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.
C programming Language and Data Structure For DIT Students.
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: 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.
Computer Science 210 Computer Organization Introduction to C.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
A First Program Using C#
Welcome In The World Of ‘C’.  TEXT BOOK: Programming in ANCI ‘C By: E Balagurusamy. TMH  Reference Books: 1) The ‘C Programming Language By: Kernighan.
“C” Programming Language What is language ? Language is medium of communication. If two persons want to communicate with each other, they have to use.
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.
Programming Design Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
Basics of “C” Programming
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
Introduction of C++ language. C++ Predecessors Early high level languages or programming languages were written to address a particular kind of computing.
C Programming language
Programming With C.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
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.
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
1 Programming in C Hello World! Soon I will control the world! Soon I will control the world!
C Programming language Basic Concepts Prepared By The Smartpath Information systems
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.
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 Basic Learning Prepared By The Smartpath Information systems
Agenda Computer Languages How to Write a Simple C Program
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Silberschatz and Galvin  C Programming Language Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University College of Education.
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.
Programming Fundamentals Enumerations and Functions.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
L071 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program Reading Sections
小型系統 心情 vs. 古典樂 心情 vs. 古典樂 浪漫求籤系統 美食導航系統 季潔亭雅鈺熒岱芸 美食導航系統 楊氏音樂模擬大會考人瑋 若維 芷萱 伽倩 楊氏音樂模擬大會考 麥當勞熱量計算系統 火星文困擾你嗎 ? 火星文困擾你嗎 ? 歌詞知多少 - 挑戰你的腦容量英琪 日馨 青雪 鈺娟.
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.
From Algorithms to Programs Both are sets of instructions on how to do a task Algorithm: –talking to humans, easy to understand –in plain (English) language.
Introduction to C Topics Compilation Using the gcc Compiler
UMBC CMSC 104 – Section 01, Fall 2016
Programming what is C++
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2017
Computer Science 210 Computer Organization
Introduction to C Language
C Programming Hardik H. Maheta.
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.
Introduction to C Topics Compilation Using the gcc Compiler
Getting Started with C.
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Hector Cen Fall 2017
Introduction to C 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
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
C programming Language
The C Language: Intro.
CSC215 Lecture Introduction.
An Overview of C.
Introduction to C Topics Compilation Using the gcc Compiler
Presentation transcript:

“C” Programming Language CIS 218

Description C is a procedural languages designed to provide lowlevel access to computer system resources, provide language constructs that map efficiently to machine instructions, and require minimal run-time support. C is useful for applications previously would have been coded in assembly language. C language was designed to encourage machine-independent programming (i.e. source code portable) for a very wide variety of computer platforms and operating systems if written in standards-compliant syntax Some early C compilers were implemented on PDP-11 processors having only 16 address bits. C compilers for several common 8-bit platforms have been implemented as well.

History The initial development of C occurred at AT&T Bell Labs between 1969 and It was named "C" because many of its features were derived from an earlier language called "B" by Ken Thompson. The Unix operating system, originally implemented in assembly language on a DEC PDP-7 by Dennis Ritchie and Ken Thompson. They later decided to port the operating system to a DEC PDP-11. The original PDP-11 version of the Unix system was developed in assembly language. B's lack of functionality to take advantage of some of the PDP-11's features, notably byte addressability, led to the development of an early version of the C programming language. By 1973, the C language had become powerful enough that most of the Unix kernel was rewritten in C. This was one of the first operating system kernels implemented in a language other than assembly. In 1978, Brian Kernighan and Dennis Ritchie published the first edition of The C Programming Language. The second edition of the book covers the later ANSI C standard.

ANSI C and ISO C In 1983, the American National Standards Institute (ANSI) formed a committee, X3J11, to establish a standard specification of C. In 1989, the standard was ratified as ANSI X "Programming Language C." with features such as data declarations, memory allocation., various data structures and enumeration types. This version of the language is often referred to as ANSI C, Standard C, or sometimes C89. In 1990, the ANSI C standard (with formatting changes) was adopted by the International Organization for Standardization (ISO) as ISO/IEC 9899:1990, which is sometimes called C90. Therefore, the terms "C89" and "C90" refer to the same programming language. The standards committee included several additional features in "C90) borrowed from C++ (Microsoft version). ANSI no longer develops the C standard independently, but defers to the ISO C standard. Current common C compilers and most portable C code being written nowadays is based on "C89". Any program written in Standard C without hardware-dependent instructions will run correctly on any platform with a conforming C implementation, within its system architecture limits.

Syntax C source code is free-form allowing arbitrary use of whitespace to format code. Comments appear either between the delimiters /* and */, or in later versions following // until the end of the line. C programming language syntax is similar to that specified in the C shell language from which the shell was derived. Every set of "logic" in C is formatted as a function; using the basic bash function syntax; even the main program Each source file contains variable declarations using keywords such as struct, union, and enum. usually by writing the type followed by the variable name. Function definitions, contain declarations and expression statements consisting of an expression to be evaluated, followed by a semicolon; Expressions can use a variety of built-in operators and may contain function calls. Keywords such as char and int specify built-in types. Sections of code are enclosed in braces ({ and }, sometimes called "curly brackets") to limit the scope of declarations and to act as a single statement for control structures. To modify the normal sequential execution of statements, C provides several control- flow statements identified by reserved keywords. if-then, while, until, case.

"Hello, world" example The "hello, world" example has become the standard example for introductory programming languages. The program prints "hello, world" to the standard output (STDOUT). The C89 standard-conforming "hello, world" program is: #include int main(void) { printf("hello, world\n"); return 0; } The first line of the program contains a preprocessing directive, indicated by #include. This causes the preprocessor — the first tool to examine source code as it is compiled — to substitute the line with the entire text of the stdio.h standard header, which contains declarations for standard input and output functions such as printf. The angle brackets surrounding stdio.h indicate that stdio.h is located using a search strategy that prefers standard headers to other headers having the same name. Double quotes may also be used to include local or project-specific header files.

"Hello, world" example (Cont.) The next line is the function main. The run-time environment calls the main function to begin program execution. The type specifier int indicates that the return value returned to the invoker (run-time environment), is an integer. The keyword void as a parameter list indicates that the main function takes no arguments. The opening curly brace indicates the beginning of the definition of the main function. The next line calls a function named printf (as declared in stdio.h) supplied from a system library. The printf function is passed a single argument, the address of the first character in the string literal "hello, world\n" ending with the \n escape sequence that C translates to a newline character. The semicolon; terminates the statement. The return statement terminates the execution of the main function and causes it to return the integer value 0, which is interpreted by the run-time system as an exit code indicating successful execution. The closing curly brace indicates the end of the code for the main function.

Libraries The C programming language uses libraries as a set of functions contained within a single "archive" file. Each library typically has a header file, prototypes of the functions contained within the library, and declarations of special data types and macro symbols used with these functions. In order for a program to use a library, it must include the library's header file. The library must be linked with the program, which in many cases requires compiler flags. The most common C library is the C standard library, which is specified by the ISO and ANSI C standards and comes with every C implementation. This library supports stream input and output, memory allocation, mathematics, character strings, and time values. Other common C library functions are those used by applications specifically targeted for Unix and Unix-like systems with functions that provide an interface to the kernel. Since many programs have been written in C, there are a wide variety of other libraries available. Libraries are often written in C because C compilers generate efficient object code; programmers then create interfaces to the library so that the routines can be used from higher-level languages like Java, Perl, and Python.

Related languages C syntax is the basis for many later languages such as Java, C#, Perl, PHP, JavaScript, LPC, and Unix's C Shell. In fact, C compilers are so efficient, most of these languages are written in C. Perl is an example of a popular programming language rooted in C. Perl's syntax closely follows C syntax. The standard Perl implementation is written in C and supports extensions written in C. Object-oriented languages C++ and Objective-C are two different extensions of C that provided object-oriented capabilities. C++ adds greater typing strength, scoping and other tools useful in object-oriented programming and permits generic programming via templates. Nearly a superset of C, C++ now supports most of C, with a few exceptions Objective-C remains a strict superset of, C that permits object-oriented programming using a dynamic/static typing model. Objective-C derives its syntax from both C and Smalltalk Because of their object orientation C++ (later C Sharp and C.NET in Microsoft) are common languages used for graphical user interfaces (i.e. Windows).

Development environments Many tools have been created to assist C programming such as automated source code checking, auditing, source code versioning, project development and packaging, program debugging. The text covers the basic tools for C program development under UNIX. There are also compilers, libraries and operating system level options for performing array bounds checking, buffer overflow detection, serialization, automatic garbage collection and code optimization that are not a part of Standard C. Language specific development environments called Integrated Development Environments (IDEs) provide GUI code development user interfaces, automatically perform code versioning, program linking and packaging and redistribution mechanisms. These IDE’s tend to be vendor specific (Microsoft, Borland). And are usually used for platform specific (i.e. non-portable) code development.