DAY 2 : BASIC OF C

5. DATA TYPE

Data Type specifies the size and type of values that can be stored in an variable.

Types :

Primary

int (2 byte) : -32768 to 32767
char (1 byte) : -128 to 127
float (4 byte) : 1.75e-38 to 3.4e+38
double (8 byte) :
void(0 byte)

Secondary

Array
Pointer
Structure
Union

Program to find Data Type Size

#include<stdio.h>
#include<conio.h>

void main( )
{

int a;
printf(“%d”, sizeof(a)); // %d is format specifier
getch( );

}

6. VARIABLES

Identifier refers to the name of memory location where we store data.

int a=20;
a is variable


Type of variable

  1. Local
  2. Global
  3. Static

Program to demonstrate local, global and static variable.

#include<stdio.h>
#include<conio.h>
int a; // global variable is used anywhere in the program
void main()
{

in b; / / local variable is used within the function
static int c; // static variable is used within the function

}
/* Local variable make memory location every time whenever it is called where as static variable make memory location only single time. */

// : Single line comment
/* /* : Multi line comment

Comment is not the part of program. It is used to explain what is done within the program.

7. Identifier

Identifier refers to the name that is used to identify variables, functions, array, pointer, structure, union.

int a;

a is identifier

void sum ( )

sum ( ) is identifier

All variables are identifier but all identifier are not variable.

Leave a Reply