Sonam +91-9537192988-Mind-blowing skills and techniques of Ahmedabad Call Girls
c
1. Introduction to ‘C’
P. Madhu Sudhana Rao
Embedded Software Developer
Presented by:
CLASS - 1
2. INDEX OF CONTENTS
• History of ‘C’
• Characteristics of ‘C’
• Structure of ‘C’
• Environment of ‘C’
• Elements of ‘C’
• How to Install Turbo C?
• How to Install GCC?
6. Features of ‘C’
• Middle Level Language.
• Application Programs & System Programs.
• Small Language with 32 English words.
• Library Functions.
• Language is Extendible.
• Structured Program.
8. C PROGRAM
• Comment Section
• Preprocessor Section
• Global Declarations Section
• Main Section
• Local Declarations Section
• Logical Blocks
• Functions
• Local Declarations Section
• Logical Blocks
// C DEMO
#include<stdio.h>
#include<conio.h>
int a;
Void main()
{
char b;
------------------------------
-------------------------------
}
Func1()
{
int c;
----------------------------------
----------------------------------
}
9. COMMENTS SECTION
• Comments are programmer friendly.
• Compiler will never execute comments.
• Two types of Comments
– Single Line Comment
• Syntax: // ……………….
– Multiple Line Comment
• Syntax: /* ………………………….
………………………….*/
10. PREPROCESSOR SECTION
• C PRE PROCESSOR
• Directives
• #include, #define etc…
• How to define constant value
– Syntax: #define mad 2.2
• How to include library file
– Syntax: #include <HedarFile.h>
11. DECLARATION SECTION
• Scope
• Two Sections
– Global Declaration
• Syntax: Data_Type Variable_name;
– Local Declaration
• Syntax: Data_Type Variable_name;
14. COMPILATION PROCESS
SOURCE CODE
PRE PROCESSOR
COMPILER
ASSEMBLER
LINKER
EXECUTABLE CODE
EXPANDED CODE
ASSEMBLY CODE
OBJECT CODE
OTHER OBJECT FILES
LIBRARIES
15. Two Compilers
• Download Turbo C from Google Drive.
• Download Code Blocks from Google Drive.
Follow the PRESENTATION…
In the practical session, download and install them
17. BASIC ELEMENTS
• Character Set
• Keywords
• Identifiers
• Data Types
• Constants
• Variables
• Expressions
• Statements
• Comments
18. CHARACTER SET
• Alphabets [a-z, A-Z]
• Digits [0 – 9]
• Escape Sequences
ESCAPE SEQUENCE MEANING
b BACKSPACE
a ALERT
r CARRIAGE RETURN
n NEWLINE
0 NULL
t HORIZONTAL TAB
BACKSLASH
20. IDENTIFIERS
• Words Keywords or Identifiers
• Rules:
– The name should consist of alphabets, digits and underscore sign.
– First character should be an alphabet or underscore.
– The name should not be a keyword.
– Since C is case sensitive, the upper case and lower case are different.
– An identifier name may be arbitrarily long.
• Only 8 preferable and upto 31.
5bc int rec# avg no
21. DATA TYPES
• Memory Allocation
• Four Fundamental
– int, char, float, double
• Size Qualifiers
– short, long
• Sign Qualifiers
– signed, unsigned
22. BASIC DATA
TYPE
DATA TYPE SIZE RANGE
char char or signed char 1 -128 to 127
unsigned char 1 0 to 255
Int int or signed int 4 -2147483648 to +2147483647
unsigned int 4 0 to 4294967295
Short int or signed short
int
2 -32768 to +32767
Unsigned short int 2 0 to 65535
Long int or signed long int 4 -2147483648 to +2147483647
Unsigned long int 4 0 to 4294967295
float float 4 3.4E-38 to 3.4E+38
double double 8 1.7E-308 to 1.7E+308
long double 10 3.4D-4932 to 1.1E+4932
32-BIT MACHINE DATA TYPES
23. CONSTANTS
• Can’t be changed throughout the execution
• 3 Types of Constants
– Numeric Constants
• Integer Constants
• Real Constants
– Character Constants
– String Constants
24. VARIABLES
• Store a value
• Declaration of Variables
– Syntax: int x;
• Initialization of Variables
– Syntax: int x=5;
27. COMMENTS
• Increases the readability of a program.
• Write anywhere in the program.
• Comments can’t be nested.
• Can’t be written inside string constant or a
character constant.
30. CONTACT
P. Madhu Sudhana Rao
Embedded Software Developer
Orange Research Labs
@: msr@orangeresearchlabs.com
WWW: madresearch.wordpress.com
31. I/O, OPERATORS in ‘C’
P. Madhu Sudhana Rao
Embedded Software Developer
Presented by:
CLASS - 2
32. INDEX OF CONTENTS
• Conversion Specifications
• Reading Input Data
• Writing Output Data
• getchar() and putchar()
• Operators
• Types
• Precedence and Associativity of Operators
38. PRINTF ()
• Used to write the data.
• Minimum no of arguments: 1
• Returns the no of characters printed.
Syntax:
printf(“control string”, variable1, variable2…);
39. Getchar () and Putchar()
• To read a character, then get
Syntax: ch=getchar();
• To write a character, then put
Syntax: putchar(ch);
43. Assignment Operators
• Storing of a value.
• Left Hand Side: Variable.
• Right Hand Side: Value.
Examples:
X=8, s=x+y-2, y=x
X+=5 [+= Compound Assignment Operator]
52. Operators Associativity
::a a::b left to right
a() a[b] a->b a[b..c] ({}) ([]) (<>) left to right
a++ a-- left to right
!a ~a (type)a ++a --a right to left!
a*b a/b a%b left to right
a+b a-b left to right
a>>b a<<b left to right
a>b a>=b a<b a<=b left to right
a==b a!=b left to right
a&b left to right
a^b left to right
a|b left to right
&& left to right
|| left to right
a?b:c right to left
= += -= *= /= %= <<= >>= &= |= ^=
right to left
@a right to left
, left to right
53. Examples
This expression is evaluated in this order
1+2*2 1+(2*2)
1+2*2*4 1+((2*2)*4)
(1+2)*2*4 ((1+2)*2)*4
1+4,c=2|3+5 (1+4),(c=(2|(3+5)))
1 + 5&4 == 3 (1 + 5) & (4 == 3)
c=1,99 (c=1),99
!a++ + ~f() (!(a++)) + (~(f()))
s == “mad" || i < 9 (s == “mad") || (i < 9)
r = s == “mad" r = (s == “mad")