C Programming Tutorial - University of North Florida
C Programming Tutorial
C PROGRAMMING TUTORIAL
Simply Easy Learning by
i
COPYRIGHT & DISCLAIMER NOTICE
All the content and graphics on this tutorial are the property of . Any content from
or this tutorial may not be redistributed or reproduced in any way, shape, or form without the written permission of . 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 site or this tutorial content contains some errors, please contact us at webmaster@
ii
Table of Contents
C Language Overview.............................................................. 1
Facts about C ............................................................................................... 1 Why to use C ? ............................................................................................. 2 C Programs .................................................................................................. 2
C Environment Setup ............................................................... 3
Text Editor................................................................................................... 3 The C Compiler ............................................................................................ 3 Installation on Unix/Linux ............................................................................. 4 Installation on Mac OS .................................................................................. 4 Installation on Windows ............................................................................... 4
C Program Structure ................................................................ 5
C Hello World Example ................................................................................. 5 Compile & Execute C Program ....................................................................... 6
C Basic Syntax......................................................................... 7
Tokens in C .................................................................................................. 7 Semicolons ; ................................................................................................ 7 Comments ................................................................................................... 8 Identifiers.................................................................................................... 8 Keywords .................................................................................................... 8 Whitespace in C ........................................................................................... 9
C Data Types ......................................................................... 10
Integer Types ............................................................................................. 10 Floating-Point Types ................................................................................... 11 The void Type ............................................................................................ 12
C Variables ............................................................................ 13
Variable Declaration in C................................Error! Bookmark not defined. Variable Initialization in C...............................Error! Bookmark not defined. Lvalues and Rvalues in C ............................................................................. 15
C Constants and Literals ........................................................ 17
Integer literals............................................................................................ 17 Floating-point literals.................................................................................. 18 Character constants.................................................................................... 18
iii
String literals.............................................................................................. 19 Defining Constants ..................................................................................... 19
The #define Preprocessor ...................................................................... 19 The const Keyword ................................................................................. 20
C Storage Classes ................................................................. 22
The auto Storage Class................................................................................ 22 The register Storage Class ........................................................................... 22 The static Storage Class............................................................................... 23 The extern Storage Class ............................................................................. 24
C Operators ........................................................................... 25
Arithmetic Operators.................................................................................. 25 Relational Operators................................................................................... 26 Logical Operators ....................................................................................... 28 Bitwise Operators....................................................................................... 29 Assignment Operators ................................................................................ 31 Misc Operators sizeof & ternary .............................................................. 33 Operators Precedence in C .......................................................................... 33
Decision Making in C.............................................................. 35
if statement ............................................................................................... 36
Syntax ..................................................................................................... 36 Flow Diagram .......................................................................................... 36 Example .................................................................................................. 36
if...else statement ...................................................................................... 37
Syntax ..................................................................................................... 37 Flow Diagram .......................................................................................... 38 Example .................................................................................................. 38
The if...else if...else Statement..................................................................... 39
Syntax ..................................................................................................... 39 Example .................................................................................................. 39
Nested if statements .................................................................................. 40
Syntax ..................................................................................................... 40 Example .................................................................................................. 40
switch statement ....................................................................................... 41
Syntax ..................................................................................................... 41 Flow Diagram .......................................................................................... 42 Example .................................................................................................. 42
Nested switch statements ........................................................................... 43
Syntax ..................................................................................................... 43 Example .................................................................................................. 43
iii
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- university of north texas my unt
- university of north texas
- university of north texas denton
- university of north texas degrees
- university of north texas denton tx
- the university of north texas
- university of north texas employment
- university of south florida college of medicine
- university of north texas at dallas email
- university of north texas at denton
- university of north texas programs
- university of north texas library