Presentation is loading. Please wait.

Presentation is loading. Please wait.

BASIC C PROGRAMMING LANGUAGE TUTORIAL infobizzs.com.

Similar presentations


Presentation on theme: "BASIC C PROGRAMMING LANGUAGE TUTORIAL infobizzs.com."— Presentation transcript:

1 BASIC C PROGRAMMING LANGUAGE TUTORIAL infobizzs.com

2 WHAT IS C LANGUAGE:-  C is mother language of all programming language.  It is system programming language.  It is procedure-oriented programming language.  It is also called mid level programming language. infobizzs.com

3 HISTORY OF C LANGUAGE:-  C programming language was developed in 1972 by Dennis Ritchie at bell laboratories of AT&T(American Telephone & Telegraph), located in U.S.A.  Dennis Ritchie is known as founder of c language.  It was developed to be used in UNIX Operating system.  It inherits many features of previous languages such as B and BPCL. infobizzs.com

4 LanguageyearDeveloped By ALGOL1960International Group BPCL1967Martin Richards B1970Ken Thompson Traditional C1972Dennis Ritchie K & R C1978Kernighan & Dennis Ritchie ANSI C 1989ANSI Committee ANSI/ISO C1990ISO Committee C991999Standardization Committee infobizzs.com

5 FEATURES OF C LANGUAGE:- There are many features of c language are given below. 1)Simple 2)Machine Independent or Portable 3)Mid-level programming language 4)structured programming language 5)Rich Library 6)Memory Management 7)Fast Speed 8)Pointers 9)Recursion 10)Extensible infobizzs.com

6 FIRST PROGRAM OF C LANGUAGE:- #include void main(){ printf("Hello C Language"); getch(); } infobizzs.com

7 PREPROCESSOR DIRECTIVES #include The #include directives “paste” the contents of the files like stdio.h and conio.h into your source code, at the very place where the directives appear. infobizzs.com

8 These files contain information about some library functions used in the program: stdio stands for “standard I/O”, conio stands for “console I/O” stdlib stands for “standard library”, string.h includes useful string manipulation functions. Want to see the files? Look in /TC/include infobizzs.com

9 GLOBAL DECLARATION #define MAX_COLS 20 #define MAX_INPUT 1000 The #define directives perform “global replacements”: every instance of MAX_COLS is replaced with 20, and every instance of MAX_INPUT is replaced with 1000 infobizzs.com

10 commonly used stdio.h functions: printf() – Output function Syntax: printf(“….”) ; scanf() – Input function Syntax: scanf(“format specifier”, &var,&var2…); infobizzs.com

11 commonly used conio.h functions: clrscr() Used to clear the screen getch() Used to get a character from ouput screen to come into the edit screen. infobizzs.com

12 Comments Text surrounded by /* and */ is ignored by computer Used to describe program int main() Program’s execution starts from the main function Parenthesis used to indicate a function int means that main "returns" an integer value Braces ({ and }) indicate a block The bodies of all functions must be contained in braces infobizzs.com

13 CHARACTER SET 256 characters are allowed in C. A – Z : 65 to 90 26 a – z : 97 to 122 26 0 – 9 : 48 to 57 10 Special symbols[ #, &, `…] 32 Control characters[\n, \t...] 34 Graphic characters 128 Total 256 infobizzs.com

14 DATA TYPES 1] Primary Integer Float Double Character 2] Derived Arrays Pointers Structure infobizzs.com o C support several different types of data, which may be represented differently within the computers memory. o Types 3] User Defined typedef enum

15 PRIMARY DATA TYPES Data Types Byte Format Specifier 1] char 1 %c signed char 1 %c unsigned char 1 %c 2] short 2 %d short signed int 2 %d short unsigned int 2 %u 3] int 2 %d signed int 2 %d unsigned int 2 %u infobizzs.com

16 Data Types Byte Format Specifier 4] long 4 %l long signed int 4 %ld long unsigned int 4 %lu 5] float 4 %f signed float 4 %f unsigned float 4 %uf 6] double 8 %lf 7] Long Double 10 %Lf infobizzs.com

17 TYPE CASTING It is used to convert on data at a time. We can have two types of type casting. Implicit Explicit o Implicit : This converts narrow type to wider type so that use can avoid the information to the system. Explicit : Explicit type casting is done by the programmer manually. When the programmer wants a result of an expression to be in particular type, then we use explicit type casting. This type casting is done by casting operators ‘( )’ and data type. infobizzs.com

18 TYPE CASTING EXAMPLE #include void main ( ) { int base, height, area; base = 5; height =3; area = (base * height)/2; printf ( “Area = %d \n”, area); } Output : Area = 7 But Incorrect ……………………. infobizzs.com

19 #include void main ( ) { int base, height, area; base = 5; height = 3; area = ((float) (base * height)/2); //explicite type casting printf ( “Area = %d \n”, area); } Output : Area = 7.5 …………………….Correct infobizzs.com

20 USER DEFINED DATA TYPE [A] Type Definition Allows user to define an identifier that would represent an existing data type Syntax: typedef type identifier Eg: typedef int units; units batch1, batch2; infobizzs.com

21 [B] Enumerated data type Syntax: enum identifier { value1, value2... valuen} Eg: enum day{ Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday} infobizzs.com


Download ppt "BASIC C PROGRAMMING LANGUAGE TUTORIAL infobizzs.com."

Similar presentations


Ads by Google