INTEGER SIGNED AND UNSIGNED

Sometimes we know in advance that we are going to store only positive value, so in that case we defined that variable as unsigned.

Ex

      unsigned short a;

      Unsigned int b;

       Unsigned long c;

 

 

#include<stdio.h>

int main()

{

  char ch;

  for(ch=0; ch<=254; ch++)

  printf(“%d%c/n”, ch, ch);

  return 0;

}

Ex

#include<stdio.h>

int main()

{

  unsigned char ch;

  for(ch=0; ch<=254; ch++)

  printf(“%d%c/n”, ch, ch);

  return 0;

}

Float and doubles

#include<stdio.h>

int main()

{

  char c;

  Unsigned char d;

  int i;

  Unsigned int j;

  short int k;

  Unsigned short int l;

  long int m;

  Unsigned long int n;

  float x;

  double y;

  long double z;

  ccanf(“%c%c”, &c, &d);

  printf(“%c%c”,c ,d);

  scanf(“%d%u”, &i, &j);

  printf(“%d%u”,i ,j);

  scanf(“%d%u”, &k, &l);

  printf(“%d%u”,k ,l);

  scanf(“%d%u”, &m, &n);

  printf(“%d%u”,m ,n);

  scanf(“%f%f%lf”, &x, &y, &z);

 printf(“%f%f%lf”,x ,y, z);

}

 

Data type

Range

Bytes

Format

Singed char

-128 to +127

1

%c

Unsigned char

0 to 255

1

%c

Signed short int

-32768 to +32767

2

%d

Unsigned short int

0 to 65535

2

%u

Signed int

-2147483648 to +2147483647

4

%d

Unsigned int

0 to 4294967295

4

%u

Signed long int

-2147483648 to +2147483647

4

%ld

Unsigned long int

0 to 4294967295

4

%lu

Flout

-3.4e38 to +3.4e38

4

%f

Double

-1.7e308 to +1.7e308

8

%lf

Long double

-1.7e4932 to +1.7e4932

10

%lf