Variables and Data type

Variable

In C it declares the type of variables by the datatype will come.

Processing 👉 Compilation 👉Assembly 👉Linking 👉Loading

Variable: A name to a memory location, declared by writing type variable_name;
                    Ex: int a;
                           int b;

Rules for defining the variable in C

Can contain alphabets, digits, and underscore (_)
A variable name can start with an alphabets only.
NO whitespace & reserved keywords is allowed
valid variables names: int rishav, float rishav 123, char _rishav34
invalid variable name: $rishav, int 77rishav, char long;

Data type

Basic Data type: int(%d), char(%c), float(%f), double
Derived Datatype: array, pointer, structure, union
Enumeration data type: emum
void Data type: void  (void means empty in C)

Data type

Memory size

Range

Char

1 byte

-128 to 127

Signed char

1 byte

-128 to 127

Unsigned char

1 byte

0 to 255

Short

2 byte

-32,768 to 32,767

Signed short

2 byte

-32,768 to 32,767

Unsigned short

2 byte

0 to 65,535

Int

2 byte

-32,768 to 32,767

Signed int

2 byte

-32,768 to 32,767

Unsigned int

2 byte

0 to 65,535

Short int

2 byte

-32,768 to 32,767

Signed short int

2 byte

-32,768 to 32,767

Unsigned short int

2 byte

0 to 65,535

Long int

4 byte

-2,147,483 to 2,147,483,647

Signed long int

4 byte

-2,147,483 to 2,147,483,647

Unsigned long int

4 byte

0 to 4,294,967,295

Float

4 byte

 

Double

8 byte

 

Long double

10 byte

 

 Ex: char c = 'c' ;

hence it will take in 4 GB RAM (memory) {4 x 1024x 1024x 1024x 1024}bits

If you want to chech the size of the character👇

#include <stdio.h>

int main()
{
    printf("%lu"sizeof(int));

    return 0;
}

Basic operators and functions

We can use [+, -, *, /] in language C
Ex:👇
printf("%d", 3+7);
output👉(10)

Comments

Popular Posts