0

Data Types & Format Specifiers


Different Types of Data Types

  1. int
  2. unsigned int
  3. long int
  4. unsigned long int
  5. float
  6. double
  7. long double
  8. char
  9. unsigned char

Data Types

Range of Data Types

Memory Utilization

Format Strings

Int

-32768 to +32767

2 Bytes

%d

unsigned int

0 to 65535

2 Bytes

%u

long int

-2147483648 to +2147483647

4 Bytes

%ld

unsigned long int

0 to 4294967295

4 Bytes

%lu

float

-3.4e38 to +3.4e38

4 Bytes

%f

double

-1.7e308 to +1.7e308

8 Bytes

%lf

long double

-1.7e4932 to +1.7e4932

10 Bytes

%Lf

char

-128 to + 127

1 Byte

%c

unsigned char

0 to 255

1 Byte

%c

0

Array হাবিজাবি


import java.util.Scanner;

public class Array
{
    public static void main(String[ ] args)
    {
        int num,i,j,k,sum;
        Scanner in = new Scanner(System.in);
        num = in.nextInt();
        int[] array = new int[num];
        sum=0;
        for(i=0; i<num; i++)
        {
            array[i]=in.nextInt();
            sum+=array[i];
        }
        System.out.printf("The list : ");
        for(i=0; i<num; i++)
        {
            System.out.printf("%d ",array[i]);
        }
        System.out.printf("\nsum : %d\nAverage: %d\n",sum,sum/num);

        int min, max;
        min=9999999;
        max=-999999;
        i=0;
        while(i<num)
        {
            max=array[i]>max?array[i]:max;
            min=array[i]<min?array[i]:min;
            i++;
        }
        System.out.printf("maximum: %d\nminimum: %d\n",max,min);
        System.out.printf("Enter the number to search : ");
        j=in.nextInt();
        for(i=k=0; i<num; i++)
        {
            if ( array[i] == j )
            {
                System.out.printf("\n%d is present at location %d.\n", j, i+1);
                k++;
            }
        }
        if(k==0)
            System.out.printf("\n%d is not present in array.\n",j);
        else
            System.out.printf("\n%d is present %d times in array.\n",j,k);

    }

}