c after correction

21
Fundamentals Of C Language By Mr. K R Biradar Mr. V D Chavan Mr. D S Patil RC_1131 1

Upload: prof-k-r-biradar

Post on 16-Jan-2017

26 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: C after correction

Fundamentals Of C LanguageBy

Mr. K R BiradarMr. V D Chavan

Mr. D S Patil

RC_1131

1

Page 2: C after correction

Contents1 Introduction to C Programming2 Fundamentals of C Compiling and Linking3 Basic Keywords in C4 Variable Storage and range used in C5 Different Data Types used in C6 Floating types in C7 Type Conversion in C8 Expression types9 Operator Precedence and Associativity10 Bitwise operators in C11 Conditional expressions.12 Scope rules

2

Page 3: C after correction

Mr. K R Biradar(Slides 4 to 8)

3

Page 4: C after correction

Important Features of C

a. It is a Low Level Language: Used

in system programming

b. C has standard in built functions

c. C language has a portability that can

run in different platform with no or

little modification in the program

INTRODUCTION TO PROGRAMMING C

Page 5: C after correction

Fundamentals of C Compiler and Linking

• Preprocessor Directives: The character starts with # in the program and which is different than the source code

• Compiler Program Modified Compiler Object Code

• Linker: Code used in the compiler to link other libraries

Page 6: C after correction

Basic Keywords in C

int float short longauto do do while sizeof

struct char typedef signed

union register void for

goto volatile continue static

If else double switch

break case return extern

Page 7: C after correction

Variable, storage and range used in C

Types of Variable

Sizeof Lowest Value

Highest Value

Int 2 bytes -32768 32767

Unsigned Char

1 byte 0 255

Signed char 1 byte -128 127

Unsigned int 2 bytes 0 65535

Page 8: C after correction

Different Data Types used in C• The different data types used in C language are• Int: (Integer) Used to declare variables of type

whole number• Char:(Character) Used to declare alphanumeric

characters• Float: (Floating Point Numbers) Used to declare

variables of type fractional numbers.• The variables used in C are long int, short int,

unsigned int, unsigned char etc

Page 9: C after correction

Mr. V D Chavan(Slides 10 to 13)

9

Page 10: C after correction

Floating points in C

10

Type Size Range

float 4 bytes 1.2e-38 to 3.4e +38

double 8 bytes 2.8e-308 to 1.7e+308

long double 16 bytes 3.4e-4932 to 1.1e+4932

Page 11: C after correction

Type conversion in C

11

Implicit conversion Explicit conversion

Int A = 552;Double B = A;

Double B = 552;Int A = (int)B;

Page 12: C after correction

Type Conversion

12

Float doubleLong

double

int Unsigned int

Long int

Page 13: C after correction

Expressions types

13

Different types of expression based on

operators position

infix expression

prefix expression

postfix expression

p+q +pq Pq+

Page 14: C after correction

Mr. D S Patil(Slides 15 to 20)

14

Page 15: C after correction

Operator Precedence and Associativity• Operator precedence helps for grouping of terms in an

expression and decides order in which an expression is evaluated.

• Some operators have higher priority than other operators.

• Associativity rule of an operator defines the order in which operators of the same precedence are evaluated in the absence of brackets.

eg: addition operator has a lower priority than division operation. K = 8 + 4/ 2;

Here k is assigned 10, after execution of above statement• The Operator which will be having higher priority in

expression is evaluated first.

Page 16: C after correction

• Below table show the higher to lower priority of the operators

from top to bottom of the table

Operator Precedence and Associatively

Category Operator AssociativityMultiplicative * / % Left to Right

Additive + - Left to RightShift << >> Left to Right

Relational < <= > >= Left to Right

Equality == != Left to Right

Bitwise AND & Left to RightBitwise XOR ^ Left to Right

Bitwise OR | Left to Right

Logical AND && Left to Right

Logical OR || Left to RightConditional ? : Right to Left

Page 17: C after correction

Bitwise operators in C• Bitwise operators perform bit by bit operation .

Bitwise Operators are: logical AND, logical OR and logical e exclusive OR.

Truth table

eg: A = 1100 , B = 1101 then A logical AND B =1100

P Q P&Q P|Q P^Q

0 0 0 0 0

0 1 0 1 1

1 0 0 1 1

1 1 1 1 0

Page 18: C after correction

Conditional Expressions• Conditional Expressions Contains 3 operands and 2

operators ( ? And : ) are used. syntax condition? expression1:expression2 • If the result of condition is satisfied, first expression is

evaluated and the result of the evaluation becomes the result of the operation. If the condition is not satisfied, then second expression is evaluated and its result becomes the result of the operation.

Page 19: C after correction

Scope Rules• A scope in any programming is a region of the

program where a defined variable can have its existence and that variable cannot be accessed outside that region.

• Variables declared in functions are local variables.

• Variables declared out side the functions are global variables.

Page 20: C after correction

Scope Rules #include<stdio.h> int d ; /*declaration of global variable*/ int main () { /* local variable declaration */ int e, f; e = 10; f = 20; d = e+ f; printf (“ e = %d, f = %d , d = %d \n“ ,e, f, d); return 0; }

Page 21: C after correction

Thank You

21