Presentation is loading. Please wait.

Presentation is loading. Please wait.

C Language B. DHIVYA 17PCA140 II MCA.

Similar presentations


Presentation on theme: "C Language B. DHIVYA 17PCA140 II MCA."— Presentation transcript:

1 C Language B. DHIVYA 17PCA140 II MCA

2 About C C was invented to write an operating system called UNIX.
C is a successor of B language, which was introduced around 1970. The language was formalized in 1988 by the American National Standard Institute. (ANSI). The UNIX OS was totally written in C by 1973.

3 C Program Structure A C program basically consists of the following parts: Preprocessor Commands Functions Variables Statements & Expressions Comments

4 Identifiers A C identifier is a name used to identify a variable, function, or any other user-defined item. An identifier starts with a letter A to Z or a to z or an underscore _ followed by zero or more letters, underscores, and digits (0 to 9). C does not allow punctuation characters such $, and % within identifiers. C is a case sensitive programming language.

5 Keywords The following list shows the reserved words in C.
auto else Long switch break enum register typedef case extern return union char float short unsigned const for signed void continue goto sizeof volatile default if static while do int double

6 Data Types In the C programming language, data types refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted.

7 Data Types Types and Description :
1. Basic Types: They are arithmetic types and consists of the two types: (a) integer types and (b) floating-point types. 2. Enumerated types: They are again arithmetic types and they are used to define variables that can only be assigned certain discrete integer values throughout the program. 3. The type void: The type specifier void indicates that no value is available. 4. Derived types: They include (a) Pointer types, (b) Array types, (c) Structure types, (d) Union types and (e) Function types.

8 Variables A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines the size and layout of the variable's memory;

9 Variables Types: Char : Typically a single octet(one byte). This is an integer type. int : The most natural size of integer for the machine. Float : A single-precision floating point value. Double : A double-precision floating point value. Void : Represents the absence of type.

10 Operators C language is rich in built-in operators and provides the following types of operators: Arithmetic Operators Relational Operators Logical Operators Bitwise Operators Assignment Operators Misc Operators

11 Decision Making in C if statement if...else statement
The if...else if...else Statement Nested if statements switch statement

12 Loops while for do…..while nested loops

13 Functions Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate functions. A function declaration tells the compiler about a function's name, return type, and parameters. A function definition provides the actual body of the function.

14 Scope of Variables Types: Local Variables Global Variables
Register Variable Static Variable

15 Arrays An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.

16 Arrays Declaring Arrays:
To declare an array in C, a programmer specifies the type of the elements and the number of elements required by an array as follows: type arrayName [ arraySize ]; Example: int a [10];

17 Files A file represents a sequence of bytes, does not matter if it is a text file or binary file. C programming language provides access on high level functions as well as low level (OS level) calls to handle file on your storage devices.

18 Files FILE *fopen( const char * filename, const char * mode );
Opening Files: FILE *fopen( const char * filename, const char * mode ); Closing a File: int fclose( FILE *fp ); Writing a File: int fputc( int c, FILE *fp ); Reading a File: int fgetc( FILE * fp );

19 THANK YOU


Download ppt "C Language B. DHIVYA 17PCA140 II MCA."

Similar presentations


Ads by Google