Presented by Nuzhat Memon Chapter 10 Introduction to C Language (PART 2 C Character set & C Tokens) Presented by: Nuzhat Memon
Presented by Nuzhat Memon Agenda 2 Alphabet -------------- Digits -------------- White spaces -------------- Special Symbols keywords -------------- identifiers -------------- variables -------------- Constants -------------- Strings -------------- Operators -------------- Special characters Instructions Program character set C Token Alphabets words sentences
Presented by Nuzhat Memon C Character Set Each language has its alphabets which can be used to form words and sentences. So does c language has its own character set. . 3
Presented by Nuzhat Memon 4 Blank space Horizontal tab Vertical tab New line Form feed 0 1 2 3 4 5 6 7 8 9 A …Z a…z C Character Set Letters Digits White Spaces Special Characters Comma , Semi colon ; Colon : Quotation mark “ Period . Apostrophe ′ Question mark ? Ampersand & At the rate @ Dollar $ Hash sign # Tilde ~ Underscore _ Exclamation ! Greater than > Less than < Equal to = Plus + Minus - Percent % Asterisk * Forward slash / Backward slash Vertical bar | Caret ^ Parenthesis () Curly braces {} Square bracket []
Presented by Nuzhat Memon C Tokens Tokens are Smallest individual units in a C program. C is basically identifies six types of token. . 5
Presented by Nuzhat Memon 6 C Tokens Keyword Identifier Constant String Operator Special character Constants are values that remain unchanged during the program execution Example: 3.14, 10, -2.5 # <> {} () [] , . ; + - * / % > < = Predefined or reserved words Example: float, int, char, if … User defined names given to variable, function or symbolic constants Example: pi, diff, main, interest … Sequence of characters enclosed in double quotes “” which end with null character ‘0’ “hello”  {‘H’, ’e’, ’l’, ’l’, ‘o’} #include<stdio.h> void main() { int qty=10; printf(“hello”); } # | include | < | stdio | . | h | > | void | main | ( | ) | { | int | qty | = | 10 | ; | printf | ( | “hello” | ) | ; | } |
Presented by Nuzhat Memon KeyworDS 7  Each Keyword has a predefined meaning  ANSI C standard supports 32 predefined words auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue f0r signed void default goto sizeof volatile do if static while
Presented by Nuzhat Memon 8 IDENTIFIER  User defined names given by user to variable, function or symbolic constant for the purpose of identification  A word that a user can construct by making use of C character set is known as identifier  It consists of set of letters(totalcost), digits(totalcost1), underscore(total_cost)  Example: pi, qty, total, principal, interest, main, difference Rule 1: The First character of variable name must be a letter or underscore (totalcost, _totalcost) Rules 2: No Special Character Variable name consists of • Letter (a-z, A-Z) • Digit (0 -9) • Underscore (_) Rule 3: No Keywords - Keyword cannot be used as a variable name. Rule 4: Maximum length of variable name as per ANSI standards is 31 characters. Rule 5: Case sensitive .. Total, total, TOTAL all are different 10
Presented by Nuzhat Memon 9 VARIABLE  A variable is basically a data name that is used to store values.  The data within the memory space is referred by a name known as variable  Unlike constants that remain unchanged during the program execution, a variable can vary and take up several values during the program execution. Cell Address/Memory location 10 name int a=10; variable value 10 a a=a+1; 11
Presented by Nuzhat Memon Exercise 10 Valid (Yes) Invalid (No) Reason Total Value No Blank space is not allowed total&value No Special character is not allowed total_value Yes Underscore is allowed _file Yes First character can be underscore 10marks No First character has to be letter or underscore mark100 Yes As first character is character so it is allowed char No Use of reserved keyword not allowed Double Yes Identifiers are case sensitive, so this is not same as keyword double INTEREST Yes Capital and small letters are part of C character set
Presented by Nuzhat Memon 11 Constants Single Character String Base 10 (0-9) 75, -99 Decimal Hexadecimal Octal 2,000 10.55 abcd Base 16 0x or 0X (0-9, A-F) 0X75, 0xA A B C D E F 10 11 12 13 14 15 Base 8 (0-7) 075, -63 096 Integer Whole numbers Real Decimal numbers with fractional part ‘a’, ‘#’, ‘3’ sequence of characters enclosed in “ “ “hello”, “a” 41.5 25.75 0.2575 e 2 Mantissa exponent Escape character a : Audible alert b : Backspace f : Form feed n : New line r : Carriage return t : Horizontal tab v: Vertical tab ’ : Single quote ” : Double quote ? : Question mark : Backslash 0: Null #define PI 3.14 #define MAX 10 Numeric Special Character Character Symbolic Constant ‘a’ ‘b’ ‘c’ …. ‘z’ 97 98 99 … 122 ‘A’ ‘B’ ‘C’ … ‘Z’ 65 66 67 … 90 0 1 2 … 3 48 49 50 … 57
Presented by Nuzhat Memon Thanks for Watching 12 You can find me at: nuzhatmemon.com nuzhat.memon@gmail.com

Std 10 computer chapter 10 introduction to c language (part2)

  • 1.
    Presented by NuzhatMemon Chapter 10 Introduction to C Language (PART 2 C Character set & C Tokens) Presented by: Nuzhat Memon
  • 2.
    Presented by NuzhatMemon Agenda 2 Alphabet -------------- Digits -------------- White spaces -------------- Special Symbols keywords -------------- identifiers -------------- variables -------------- Constants -------------- Strings -------------- Operators -------------- Special characters Instructions Program character set C Token Alphabets words sentences
  • 3.
    Presented by NuzhatMemon C Character Set Each language has its alphabets which can be used to form words and sentences. So does c language has its own character set. . 3
  • 4.
    Presented by NuzhatMemon 4 Blank space Horizontal tab Vertical tab New line Form feed 0 1 2 3 4 5 6 7 8 9 A …Z a…z C Character Set Letters Digits White Spaces Special Characters Comma , Semi colon ; Colon : Quotation mark “ Period . Apostrophe ′ Question mark ? Ampersand & At the rate @ Dollar $ Hash sign # Tilde ~ Underscore _ Exclamation ! Greater than > Less than < Equal to = Plus + Minus - Percent % Asterisk * Forward slash / Backward slash Vertical bar | Caret ^ Parenthesis () Curly braces {} Square bracket []
  • 5.
    Presented by NuzhatMemon C Tokens Tokens are Smallest individual units in a C program. C is basically identifies six types of token. . 5
  • 6.
    Presented by NuzhatMemon 6 C Tokens Keyword Identifier Constant String Operator Special character Constants are values that remain unchanged during the program execution Example: 3.14, 10, -2.5 # <> {} () [] , . ; + - * / % > < = Predefined or reserved words Example: float, int, char, if … User defined names given to variable, function or symbolic constants Example: pi, diff, main, interest … Sequence of characters enclosed in double quotes “” which end with null character ‘0’ “hello”  {‘H’, ’e’, ’l’, ’l’, ‘o’} #include<stdio.h> void main() { int qty=10; printf(“hello”); } # | include | < | stdio | . | h | > | void | main | ( | ) | { | int | qty | = | 10 | ; | printf | ( | “hello” | ) | ; | } |
  • 7.
    Presented by NuzhatMemon KeyworDS 7  Each Keyword has a predefined meaning  ANSI C standard supports 32 predefined words auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue f0r signed void default goto sizeof volatile do if static while
  • 8.
    Presented by NuzhatMemon 8 IDENTIFIER  User defined names given by user to variable, function or symbolic constant for the purpose of identification  A word that a user can construct by making use of C character set is known as identifier  It consists of set of letters(totalcost), digits(totalcost1), underscore(total_cost)  Example: pi, qty, total, principal, interest, main, difference Rule 1: The First character of variable name must be a letter or underscore (totalcost, _totalcost) Rules 2: No Special Character Variable name consists of • Letter (a-z, A-Z) • Digit (0 -9) • Underscore (_) Rule 3: No Keywords - Keyword cannot be used as a variable name. Rule 4: Maximum length of variable name as per ANSI standards is 31 characters. Rule 5: Case sensitive .. Total, total, TOTAL all are different 10
  • 9.
    Presented by NuzhatMemon 9 VARIABLE  A variable is basically a data name that is used to store values.  The data within the memory space is referred by a name known as variable  Unlike constants that remain unchanged during the program execution, a variable can vary and take up several values during the program execution. Cell Address/Memory location 10 name int a=10; variable value 10 a a=a+1; 11
  • 10.
    Presented by NuzhatMemon Exercise 10 Valid (Yes) Invalid (No) Reason Total Value No Blank space is not allowed total&value No Special character is not allowed total_value Yes Underscore is allowed _file Yes First character can be underscore 10marks No First character has to be letter or underscore mark100 Yes As first character is character so it is allowed char No Use of reserved keyword not allowed Double Yes Identifiers are case sensitive, so this is not same as keyword double INTEREST Yes Capital and small letters are part of C character set
  • 11.
    Presented by NuzhatMemon 11 Constants Single Character String Base 10 (0-9) 75, -99 Decimal Hexadecimal Octal 2,000 10.55 abcd Base 16 0x or 0X (0-9, A-F) 0X75, 0xA A B C D E F 10 11 12 13 14 15 Base 8 (0-7) 075, -63 096 Integer Whole numbers Real Decimal numbers with fractional part ‘a’, ‘#’, ‘3’ sequence of characters enclosed in “ “ “hello”, “a” 41.5 25.75 0.2575 e 2 Mantissa exponent Escape character a : Audible alert b : Backspace f : Form feed n : New line r : Carriage return t : Horizontal tab v: Vertical tab ’ : Single quote ” : Double quote ? : Question mark : Backslash 0: Null #define PI 3.14 #define MAX 10 Numeric Special Character Character Symbolic Constant ‘a’ ‘b’ ‘c’ …. ‘z’ 97 98 99 … 122 ‘A’ ‘B’ ‘C’ … ‘Z’ 65 66 67 … 90 0 1 2 … 3 48 49 50 … 57
  • 12.
    Presented by NuzhatMemon Thanks for Watching 12 You can find me at: nuzhatmemon.com nuzhat.memon@gmail.com