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.

Slides:



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

Chapter 3: Beginning Problem Solving Concepts for the Computer Programming Computer Programming Skills /1436 Department of Computer Science.
CIS 101: Computer Programming and Problem Solving Lecture 8 Usman Roshan Department of Computer Science NJIT.
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)
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.
CSE : Programming in C Instructor: Lei Wang Office: Dreese Lab 474 Office Hour: Friday.
Introduction to C Topics Compilation Using the gcc Compiler
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
CHAPTER 1: INTORDUCTION TO C LANGUAGE
Computer Science 210 Computer Organization Introduction to 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.
Introduction of C++ language. C++ Predecessors Early high level languages or programming languages were written to address a particular kind of computing.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software.
CSCI 130 Chapter 1. History of C Bell Telephone Laboratories (1972) Dennis Ritchie (also created UNIX) A - B - C.
H.Melikian Introduction on C C is a high-level programming language that forms the basis to other programming languages such as C++, Perl and Java. It.
Language C (1) By Randa. Generalities: Types of programmes: -operating system ”système d’exploitation” like Windows XP, Windows 98, Unix, Linux… -programmes.
Computer Programming A program is a set of instructions a computer follows in order to perform a task. solve a problem Collectively, these instructions.
Programming With C.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
Introduction to C++ Programming Language
CSE 2541 – Advanced C Programming. Course info Prereq – CSE 2221 or CSE 222 Co-req – CSE 2231 Website
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.
C Language: Introduction
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.
1 Original Source : and Problem and Problem Solving.ppt.
Introduction to C CMSC 104, Section 4 Richard Chang 1.
Introduction to C 2008/09/29: Lecture 7 CMSC 104, Section 0101 John Y. Park 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.
CMSC 1041 Introduction to C Creating your first C program.
Agenda Computer Languages How to Write a Simple C Program
Department of Electronic & Electrical Engineering Introduction to C - The Development cycle. Why C? The development cycle. Using Visual Studio ? A simple.
First Compilation Rudra Dutta CSC Spring 2007, Section 001.
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.
C Programming Lecture 3 : C Introduction 1 Lecture notes : courtesy of Woo Kyun and Chang Byung-Mo.
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 PROGRAMING System Development Mansoura October 2015.
C language--Introduction. History 1970: B by Ken Thompson at AT&T Bell Lab 1972: C by Dennis Ritchie and Ken Tompson at At&T Bell Lab for UNIX 1978: “The.
KYC - Know your compiler Introduction to GCC
Chapter 5: Preparing C Programs
Introduction to C Topics Compilation Using the gcc Compiler
UMBC CMSC 104 – Section 01, Fall 2016
Computer Science 210 Computer Organization
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
Introduction to C Topics Compilation Using the gcc Compiler
Introduction to C Topics Compilation Using the gcc Compiler
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
Govt. Polytechnic,Dhangar
Introduction to C Topics Compilation Using the gcc Compiler
Creating your first C program
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.
2008/09/29: Lecture 7 CMSC 104, Section 0101 John Y. Park
Your first C and C++ programs
Introduction to C Topics Compilation Using the gcc Compiler
Introduction to C Topics Compilation Using the gcc Compiler
Presentation transcript:

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. There are only 27 keywords in the original version of C. – for, goto, if, else …… Easy to build a compiler for C. – Many people have written C compilers – C compilers are available for virtually every platform In 1983 the American National Standards Institute (ANSI) formed a committee to establish a standard definition. – Called ANSI Standard C. – As opposed to K&R C (referring to the general “standards” that appeared in the first edition of Brian Kernighan and Ritchie’s influential book: The C Programming Language)

Why use C ? C is intended as a language for programmers – BASIC was for nonprogrammers to program and solve simple problems. – C was created, influenced, and field-tested by working programmers. C is powerful and efficient – You can nearly achieve the efficiency of assembly code. – System calls and pointers allow you do most of the things that you can do with an assembly language. C is a structured language – Code can be written and read much easier. C is standardized – Your ANSI C program should work with any ANSI C compiler.

Development Cycle of C Edit Program Source Code Compile Object Code Link Object Code Executable Library Files

Compilation (1) Compilation translates your source code (in the file hello_world.c) into object code (machine dependent instructions for the particular machine you are on). – Note the difference with Java: The javac compiler creates Java byte code from your Java program. The byte code is then executed by a Java virtual machine, so it’s machine independent. Linking the object code will generate an executable file. There are many compilers for C under Unix – SUN provides the Workshop C Compiler, which you run with the cc command – There is also the freeware GNU compiler gcc

Compilation (2) To compile a program: u Compile the program to object code. >> gcc –c hello_world.c u Link the object code to executable file. >> gcc hello_world.o –o hello You can do the two steps together by running: >> gcc hello_world.c –o hello To run your program: >> hello If you leave off the -o, executable goes into the file a.out

Example 1 – Hello World #include int main ( ) { printf ("Hello, World!\n"); return 0; }

Error Messages Error messages can be quite descriptive, or really terse. Suppose you forgot the semi-colon after the printf >> gcc hello.c –o hello "hello.c", line 5: syntax error before or at: return gcc: acomp failed for hello.c Notice that the compiler flags and informs you about the error at the first inappropriate token. – In this case, the return statement. Always try to fix problems starting with the first error the compiler gives you - the others may disappear too!

Example 2 – Calculate Area of a Circle #include int main () { int radius; float area; printf ("Enter radius : "); scanf ( "%d", &radius); area = * radius * radius; printf ("\n Area = %f \n\n", area); return 0; }

Example 3 - Loops #include int main () { int i; for (i = 0; i < 10; i++) { printf ( "A\n"); } return 0; }

Example 4 - Functions /* Program to calculate the product of two numbers */ #include int product(int x, int y); int main () { int a,b,c; /* Input the first number */ printf ("Enter a number between 1 and 100: "); scanf ("%d", &a); /* Input the second number */ printf ("Enter another number between 1 and 100: "); scanf ("%d", &b); /* Calculate and display the product */ c = product (a, b); printf ("%d times %d = %d \n", a, b, c); return 0; } /* Functions returns the product of its two arguments */ int product (int x, int y) { return (x*y); }