C Programming language Basic Concepts Prepared By The Smartpath Information systems www.thesmartpath.in.

Slides:



Advertisements
Similar presentations
C Language.
Advertisements

Chapter 3: Beginning Problem Solving Concepts for the Computer Programming Computer Programming Skills /1436 Department of Computer Science.
11-2 Identify the parts of the “main” function, which include Preprocessor Directives main function header main function body which includes Declaration.
Lecture 2 Introduction to C Programming
Introduction to C Programming
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C Programming
Structure of a C program
 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.
Introduction to C Programming
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 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
C Programming. Chapter – 1 Introduction Study Book for one month – 25% Learning rate Use Compiler for one month – 60%
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
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.
Basics of “C” Programming
C Programming language
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Dennis Ritchie 1972 AT & T Bell laboratories (American Telephone and Telegraph) USA 1www.gowreeswar.com.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
VARIABLES, CONSTANTS, OPERATORS ANS EXPRESSION
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
 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.
MAHENDRAN. Session Objectives Session Objectives  Discuss the Origin of C  Features of C  Characteristics of C  Current Uses of C  “C” Programming.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
BASIC C PROGRAMMING LANGUAGE TUTORIAL infobizzs.com.
INTRODUCTION TO PROGRAMING System Development Mansoura October 2015.
Introduction to C Programming I Subject: T0016 – ALGORITHM AND PROGRAMMING Year: 2013.
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.
Computer Science 210 Computer Organization
Chapter 2 - Introduction to C Programming
Yanal Alahmad Java Workshop Yanal Alahmad
C Language VIVA Questions with Answers
History of ‘C’ Root of the morden language is ALGOL It’s first
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
C Short Overview Lembit Jürimägi.
Introduction to C Programming Language
' C ' PROGRAMMING SRM-MCA.
Chapter 2 - Introduction to C Programming
Introduction to C Programming
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.
Visit for more Learning Resources
Computer Science 210 Computer Organization
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
Basics of ‘C’.
Chapter 2 - Introduction to C Programming
Introduction to C Programming
Govt. Polytechnic,Dhangar
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.
Govt. Polytechnic,Dhangar
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
C – Programming Language
C Language B. DHIVYA 17PCA140 II MCA.
Course Outcomes of Programming In C (PIC) (17212, C203):
Introduction to C Programming
Presentation transcript:

C Programming language Basic Concepts Prepared By The Smartpath Information systems

Index 1. Brief History of C Language 2. About C Programming Language 3. Characteristics of C programming language 4 C Programming Environment 5. Installing C in Windows 6. C Program Structure 7. C Program Structure – Explained 8. C programming – Syntax 9. C Character Set 10. Keywords 11. Operators in C 12. Operators in C ( continue…..)

Index 13. Data Types in C 14. Data Types in C 15. Data Types in C 16. Variables 17. Rules for Variable Declaration 18. Variables Scope 19. Input and Output 20. Decision Making 21. Looping 22. Looping 23. C Libraries 24. Uses of C

Brief History of C Language The origin of C is closely tied to the development of the UNIX operating system, originally implemented in assembly language on a PDP-7 by Ritchie and Thompson. The development of C started in 1972 on the PDP-11 Unix system and first appeared in Version 2 Unix. In 1978, Brian Kernighan and Dennis Ritchie published the first edition of The C Programming Language. This book, known to C programmers as "K&R“. ANSI –C - 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

About C Programming language The C programming language is a structure oriented programming language, developed at Bell Laboratories in 1972 by Dennis Ritchie  C programming language features were derived from an earlier language called “B” (Basic Combined Programming Language – BCPL)  C language was invented for implementing UNIX operating system  In 1978, Dennis Ritchie and Brian Kernighan published the first edition “The C Programming Language” and commonly known as K&R C  In 1983, the American National Standards Institute (ANSI) established a committee to provide a modern, comprehensive definition of C. The resulting definition, the ANSI standard or “ANSI C”, was completed late 1988.

Characteristics of C programming language  There is a small, fixed number of keywords, including a full set o flow of control and primitive.  There are a large number of arithmetical and logical operators, such as +, +=, ++, &, ~, etc.  Typing is static but weakly enforced all data has a type, but implicit conversions can be performed; for instance, characters can be used as integers.  Strings are not a separate data type, but are conventionally implemented As null terminated array of characters  Enumerated are possible with the enum keyword. They are not tagged, and are freely interconvertible with integers.

C programming Environment The C programming environment consists of - (1) Text Editor - Programs are typed in Text Editor. By default a new file Noname.c is opened. Type your programs here, save it, compile and run. (2) Compiler – Compiler is a System software that is installed on computer to compile and run programs. Most widely Turbo C compiler is used

Installing C in Windows To install C in windows first download Turbo C compiler.. 1. unzip the downloaded file. And run the install.exe file 2. Press ‘Enter’ to continue 3. Enter Source drive where C-compiler and editor will be saved. 4. Enter the source path to locate the exe file. Press ‘Enter’ key. 5. using arrow key, scroll down. Select start installation 6. A message is displayed after successful installation. 7. Go to C:\TC\BIN right click TC icon select create shortcut.

C Program Structure A C program contains the following – (a) preprocessor commands (b) main( ) function ( c ) variables (d) input and output functions For example : #include /* this is comment line */ #include Void main() { printf(“hello”); getch(); }

C Program structure Explained 1. #include - The first two lines are preprocessor commands that tell the compiler that the program is using functions in it. 2.Void main() - This is the main function. Program execution begins with the this function only. 3.Variables - variables hold input and output values. 4. printf() - this is function to give output on the screen. The word “hello” is displayed on output screen. 5. The getch() – It is a function that ends program and returns to program window.

C Programming - Syntax for writing programs 1. C language is case sensitive language. Hello and hello are two different words. 2. Programs are written in small caps only ie.. In small letters.Capital words are treated differently. 3. Inside the main() function, each statement is terminated with semicolon. 4. Comments are used for explanation. /* ….. */ format is used to give comments in program. They are not executed.

C Character Set The basic C source character set includes the following characters Lowercase and uppercase letters: a–z, A–Z Decimal digits: 0–9 Graphic characters: ! " # % & ' ( ) * +, -. / : ; ? [ \ ] ^ _ { | } ~ Whitespace characters – space, horizontal tab, vertical tab new line, form feed

Keywords

Operators in C C supports a rich set of operators, which are symbols used within an expression to specify the manipulations to be performed while evaluating that expression. C has operators for 1. Arithmetic operators 2. Relational operators addition + Equals == subtraction - Not Equal != Multiplication * Greater than > Division / Greater than equal to >= Modulus % Less than < Less than equal to <=

Operators in C 3. Logical operators logical AND && 8. function call ( ) logical OR || 9. object size sizeof( ) logical NOT ! 10. Bitwise 4. increment ++ left shift << decrement -- right shift >> 5. Assignment operator = 6. Member selection. ->

Data Types in C 1. Basic data types Data Type Format Specified Space occupied char %c 1 byte signed char %c 1 byte int %d 2 bytes signed short int %hi 2 bytes long int %ld 4 bytes float %f 4 bytes double %lf 8 bytes long double %Lf 10 bytes

Data Types in C 2. Derived data types - The derived data types are (i) Pointer (ii) Array (iii) Structure (iv) Union (v) Function

Data Types in C 3. User defined data types - Typedef is used to create user defined data type in C for example structures are declared with typedef to create linked list data structures in C. For Example : typedef struct node { int n; node * p; }

Variables Variables in C is valid name in the memory where input given by user is stored and the result of program is stored. When a variable is declared in program, it occupies space in memory according to its size. Such as integer type takes 2 bytes of memory, char type takes 1 byte of memory Example: int sum; float average; char ch; Here int,float, char are basic data types. And Sum, average and ch are variables..

Rules for declaring variables 1. A variable name should start with letter. 2. It should not be a keyword 3. It can contains underscore character. 4. It should not contain white spaces and special characters. Example: sum - valid 1sum - invalid emp_id - valid emp id - invalid

Variables scope In C language variables have the following scopes 1. Local Scope - Variable declared inside main(), and variable declared inside a function has local scope that is it is recognized inside it local variable can be used inside that block of code. 2. Global Scope - variables declared outside the main() function are global variable. They are recognized throughout the program. They can be used by any function.

Input and output C has functions predefined for taking user input in a program and giving output in the screen scanf( ) - the scanf() function takes variable number of arguments from user in predefined format format - scanf(“%d%c%f”, &a, &b, &c); printf() - the printf() function gives output of program on the output screen format - printf(“%d%c%f ”, a, b, c );

Decision making Decision making requires that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and other statements to be executed if the condition is determined to be false Statements used are - 1. simple if 2. if – else 3. if-else ladder 4. nested if – else 5. conditional operator

Decision making Examples : 1. simple if if( condition1) { statements; } if(condition 2) {statements ; } 2. if – else if(condition true) { statements; } else { condition false}

Looping There may be a situation, when you need to execute a block of code several number of times. In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. Statements inside the loop are executed till condition is true or condition gets False. There are three types of loops in C 1. For Loop 2. While Loop 3. Do -While Loop

Looping Examples : 1. For Loop for(initialization ; condition; increm / decrem) { statements; } 2. While Loop while(condition) { statements ; } 3. Do -While Loop do { statements } while( condition );

C Libraries C language contains set of files header files called library. These header files Have ‘.h’ extension. They contain functions for various types of operations Performed in a program. To use them we have to include them in a program Through include statement. Some of C Library header files are – stdio.h conio.h stdlib.h graphics.h

Uses of C C is widely used for "system programming", including implementing operating systems and embedded system applications, due to a combination of desirable characteristics such as code portability and efficiency, ability to access specific hardware addresses, ability to match externally imposed data access requirements, and low run-time demand on system resources. C can also be used for website programming using CGI as a "gateway" for information between the Web application, the server, and the browser Some reasons for choosing C over interpreted languages are its speed, stability, and near-universal availability C has also been widely used to implement end-user applications, but much of that development has shifted to newer, higher-level languages.