Download as pdf
Download as pdf
You are on page 1of 7
C Programming Tutorial C PROGRAMMING TUTORIAL Simply Easy Learning by tutorialspoint.com COPYRIGHT & DISCLAIMER NOTICE © All the content and graphics on this tutorial are the property of tutorialspoint.com. Any content from tutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or form without the written permission of tutorialspoint.com. Failure to do so is a violation of copyright laws. This tutorial may contain inaccuracies or errors and tutorialspoint provides no guarantee regarding the accuracy of the site or its contents Including this tutorial. If you discover that the tutorialspoint.com site or this tutorial content contains some errors, please contact us at webmaster@tutorialspoint.com Table of Contents C Language Overview... Facts about C Why to use C?.. C Programs C Environment Setup . Text Editor... The C Compiler Installation on Unix/Linux . Installation on Mac OS.... Installation on Windows C Program Structure C Hello World Example Compile & Execute C Program .. C Basic Syntax. Tokens in C.... Semicolons ; . Comments Identifiers. Keywords .. Whitespace in C C Data Types Integer Types... Floating-Point Types The void Type ... C Variables Variable Declaration in C © SSOBVVNOAMARROWWNNAS Error! Bookmark not defined. Variable Initialization in Error! Bookmark not defined. Lvalues and Rvalues in C.... seseeseeee 15) C Constants and Literals 17 Integer literals... eeseeseeee 17 Floating-point literals. 18 Character constants. sevsneneeeee 18 String literals Defining Constants ... ‘The #define Preprocessor... ‘The const Keyword C Storage Classes The auto Storage Class. The register Storage Class 22 The static Storage Class. The extern Storage Class C Operators . Arithmetic Operators. Relational Operators. Logical Operators... Bitwise Operators. Assignment Operators Misc Operators +4 sizeof & ternary .. Operators Precedence in C. Decision Making in C... if statement. Syntax 36 Flow Diagram... Example if...else statement Syntax Flow Diagram... Example The if...else if...else Statement. 39 Syntax 39 Example... 7 . eeeeennnnn 38 Nested if statements Syntax 40 Example 40 switch statement . ‘Syntax 44 Flow Diagram... Example Nested switch statements. ‘Syntax 43 Example 43 The ? : Operator. 44 C Loops. . - - while loop in C 46 Syntax 46 Flow Diagram... Example for loop in C Syntax Flow Diagram. Example do...while loop in C. Syntax Flow Diagram... Example nested loops in C syntax 51 Example break statement in C.... Syntax Flow Diagram sn Example continue statement in C.. Syntax Flow Diagram ss Example... goto statement in C.. Syntax. 56 Flow Diagram nu Example The Infinite Loop C Functions Defining a Function .. Example Function Declarations... Calling a Function. Function Arguments Function call by value 62 Function call by reference. C Scope Rules Local Variables Global Variables Formal Parameters. Initializing Local and Global Variables C Arrays Declaring Arrays Initializing Arrays Accessing Array Element: Multi-dimensional Array: Two-Dimensional Arrays Initializing Two-Dimensional Arrays. Accessing Two-Dimensional Array Elements ... Passing Arrays as Function Arguments Way-1 Way-2... Way-3... Example Return array from function. Pointer to an Array... C Pointers z What Are Pointers? How to use Pointers? NULL Pointers in C Pointer arithmetic... Incrementing a Pointer Decrementing a Pointer. Pointer Comparisons Array of pointers... Pointer to Pointer. Passing pointers to functions. Return pointer from functions... C Strings .. C Structures...... Defining a Structure.. Accessing Structure Members Structures as Function Arguments - Pointers to Structures. 97 C Unions... . soe . 100 Defining a Union 100

You might also like