Fundamentals Of C Language
By
Mr. K R Biradar
Mr. V D Chavan
Mr. D S Patil
RC_1131
1
Contents
1 Introduction to C Programming
2 Fundamentals of C Compiling and Linking
3 Basic Keywords in C
4 Variable Storage and range used in C
5 Different Data Types used in C
6 Floating types Variables used in C
7 Type Conversion in C Language
8 Expression types
9 Operator Precedence and Associativity
10 Bit-wise operators in C
11 Conditional statements.
12 Scope rules
2
Mr. K R Biradar
(Slides 4 to 8)
3
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
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
Basic Keywords in C
int float short long
auto do do while sizeof
struct char typedef signed
union register void for
goto volatile continue static
If else double switch
break case return extern
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
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
Mr. V D Chavan
(Slides 10 to 13)
9
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
Type conversion in C Language
11
Implicit conversion Explicit conversion
int A = 552;
double B = A;
Double B = 552;
int A = (int)B;
Type Conversion
12
Float double
Long
double
int Unsigne
d int
Long int
Expressions types
13
Different types of expression based on
operators position
infix
expression
prefix
expression
postfix
expression
p+q +pq Pq+
Mr. D S Patil
(Slides 15 to 20)
14
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 = 10 + 4/ 2;
Here k is assigned 12, after execution of above
statement
• The Operator which will be having higher priority in
expression is evaluated first.
• Below table show the higher to lower priority of the
operators
from top to bottom of the table
Operator Precedence and Associatively
Category Operator Associativity
Multiplicative * / % Left to Right
Additive + - Left to Right
Shift << >> Left to Right
Relational < <= > >= Left to Right
Equality == != Left to Right
Bitwise AND & Left to Right
Bitwise XOR ^ Left to Right
Bitwise OR | Left to Right
Logical AND && Left to Right
Logical OR || Left to Right
Conditional ? : Right to Left
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
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.
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.
Scope Rules
#include<stdio.h>
int d ; /*declaration of global variable*/
int main ()
{
/* local variable declaration */
int e=10, f=20;
d = e+ f;
printf (“ e = %d, f = %d,d = %d n“ ,e, f, d);
return 0;
}
Thank You
21

Fundamentals of c language

  • 1.
    Fundamentals Of CLanguage By Mr. K R Biradar Mr. V D Chavan Mr. D S Patil RC_1131 1
  • 2.
    Contents 1 Introduction toC Programming 2 Fundamentals of C Compiling and Linking 3 Basic Keywords in C 4 Variable Storage and range used in C 5 Different Data Types used in C 6 Floating types Variables used in C 7 Type Conversion in C Language 8 Expression types 9 Operator Precedence and Associativity 10 Bit-wise operators in C 11 Conditional statements. 12 Scope rules 2
  • 3.
    Mr. K RBiradar (Slides 4 to 8) 3
  • 4.
    Important Features ofC 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
  • 5.
    Fundamentals of CCompiler 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
  • 6.
    Basic Keywords inC int float short long auto do do while sizeof struct char typedef signed union register void for goto volatile continue static If else double switch break case return extern
  • 7.
    Variable, storage andrange 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
  • 8.
    Different Data Typesused 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
  • 9.
    Mr. V DChavan (Slides 10 to 13) 9
  • 10.
    Floating points inC 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
  • 11.
    Type conversion inC Language 11 Implicit conversion Explicit conversion int A = 552; double B = A; Double B = 552; int A = (int)B;
  • 12.
  • 13.
    Expressions types 13 Different typesof expression based on operators position infix expression prefix expression postfix expression p+q +pq Pq+
  • 14.
    Mr. D SPatil (Slides 15 to 20) 14
  • 15.
    Operator Precedence andAssociativity • 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 = 10 + 4/ 2; Here k is assigned 12, after execution of above statement • The Operator which will be having higher priority in expression is evaluated first.
  • 16.
    • Below tableshow the higher to lower priority of the operators from top to bottom of the table Operator Precedence and Associatively Category Operator Associativity Multiplicative * / % Left to Right Additive + - Left to Right Shift << >> Left to Right Relational < <= > >= Left to Right Equality == != Left to Right Bitwise AND & Left to Right Bitwise XOR ^ Left to Right Bitwise OR | Left to Right Logical AND && Left to Right Logical OR || Left to Right Conditional ? : Right to Left
  • 17.
    Bitwise operators inC • 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
  • 18.
    Conditional Expressions • ConditionalExpressions 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.
  • 19.
    Scope Rules • Ascope 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.
  • 20.
    Scope Rules #include<stdio.h> int d; /*declaration of global variable*/ int main () { /* local variable declaration */ int e=10, f=20; d = e+ f; printf (“ e = %d, f = %d,d = %d n“ ,e, f, d); return 0; }
  • 21.