Character Sets,Constant,Variable and Data types


Character sets 

The C character set consist of upper and lowercase alphabets, digits, special characters and white spaces. The alphabet and digits are altogether called as alphanumeric character. 

Special Characters 


, comma 

. period 

; semicolon 

: colon 

# number sign 

‘  apostrophe 

 “  quotation mark 

! Exclamation mark 

 |  Vertical bar 

~ tilde 

opening angle bracket 

>  closing angle bracket 

_ under score 

$  dollar sign 

(  left parenthesis 

)  right parenthesis 

% percent sign 

}  right brace 

 & ampersand 

^  caret 

 

 -  minus 

plus sign 

 

 ] right bracket 

{ left brace 

 

 

White space character :Blank space , newline, carriage return, horizontal tab, vertical tab etc.... 

 

Constants 

 In real world, a constant is an entity that cannot change with time. In C programming, a constant is an identifier, which is used to store a value, and its value cannot be changed once assigned. We use const keyword to declare a constant.

                 Syntax

                  const   data_type  identifier=value;

                 example:-    const int a=2;

Simple program for a constant

#include<stdio.h>

#include<conio.h>

void main()

{

      const int a =2;

      printf("value of a=%d\n",a);

      getch();

}


Variable 

A variable is a unit where you store a value. They are the labels representing the memory blocks where the values are stored. A variable is declared by the combination od identifier name and the types.

                 Syntax

               data_type  variable;

              Example:-   int a;

Note:-    You can also declare more than one variable by using the separator comma(,)  like int a,b,c;

Simple program for a variable      

#include<stdio.h>

#include<conio.h>

void main()

{

        int a;       //same as int a=2;

        a=2;

        printf("value of a=%d", a);

        getch();

}


Keywords 

Keywords are those words whose meaning has been already defined to C compiler. C contains 32  keywords.

These keywords cannot be used as variable names because if we do so, we are trying to change their meaning, which is not allowed.

auto 

extern 

Size of 

Break 

float 

static 

case 

for 

struct 

char 

Go to 

switch 

const 

if 

typedef 

continue 

int 

union 

default 

long 

unsigned 

do 

register 

void 

double 

return 

volatile 

else 

short 

while 

Enum 

signed 

 

 

 



Data types 

The data types of a value (or variable in some contexts) is an attribute that tells what kind of data that value can have. The types of a variable determine how much space it occupies in storage and how the bit pattern stored is interpreted. Or  Data types are the types of data 

used in C-programming. 

We have two types of data types: -  

  1. Primary data type (e.g.:- int,char,float) 

      -  Primary data types are those data types which are already defined in the programming languages also called primitive or in-built data types. 

  1. Derived data type (e.g.:- array, pointer etc.) 

      - The data types that are derived from primary data types is called derived data types. 

 

Escape Sequences 

Character combinations consisting of a backslash (\) followed by a letter or by a combination of digits is called “escape sequences”. It tells the computer or software program to perform a function or command. 

Some Escape Sequences Symbol are given below: -  

Character 

Escape sequence 

ASCII value 

Newline  

\n 

10 

Horizontal tab 

\t 

9 

Vertical Tab 

\v 

11 

Backspace 

\b 

8 

Bell alert 

\a 

7 

Quotation mark 

\” 

34 

Apostrophe 

\’ 

39 

Question mark 

\? 

63 

Backslash 

\\ 

92 

Null 

\0 

0 

Carriage Return 

\r 

013 

 






No comments:

Post a Comment

theengineerschoice01@gmail.com