This document provides an introduction to fundamentals of the C programming language. It covers topics such as compiling and linking C code, basic keywords, variable types and ranges, data types, floating point variables, type conversion, expressions, operators precedence and associativity, bitwise operators, conditional statements, and scope rules. The document is presented over multiple slides by three authors, with each author covering several related topics in the C language.
1. Fundamentals Of C Language
By
Mr. K R Biradar
Mr. V D Chavan
Mr. D S Patil
RC_1131
1
2. 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
4. 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
5. 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
6. 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
7. 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
8. 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
10. 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
11. Type conversion in C Language
11
Implicit conversion Explicit conversion
int A = 552;
double B = A;
Double B = 552;
int A = (int)B;
15. 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.
16. • 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
17. 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
18. 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.
19. 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.
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;
}