Friday, November 23, 2012

CHECK MAXIMUM VALUE THAT CAN BE REPRESENTED IN ALL THE STORAGE TYPES. [ int(short,long,signed,unsigned), char, double, float]

/* 1. CHECK MAXIMUM VALUE THAT CAN BE REPRESENTED IN ALL THE 
        STORAGE  TYPES. [ int(short,long,signed,unsigned), char, double, float]
*/

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

void main()
{
            int size;
            clrscr();

            size=sizeof(short int);
            printf("max value in short int is ------>%lf\n",pow(2,size*8-1)-1);

            size=sizeof(long int);
            printf("max value in long int is ------->%lf\n",pow(2,size*8-1)-1);

            size=sizeof(int);
            printf("max value in signed int is ----->%lf\n",pow(2,size*8-1)-1);

            size=sizeof(unsigned int);
            printf("max value in unsigned int is --->%lf\n",pow(2,size*8));

            size=sizeof(char);
            printf("max value in char is ----------->%lf\n",pow(2,size*8-1)-1);

            size=sizeof(double);
            printf("max value in double is --------->%lf\n",pow(2,size*8-1)-1);

            size=sizeof(float);
            printf("max value in float is ---------->%lf\n",pow(2,size*8-1)-1);

            getch();
}











/*

            =====OUT PUT=====

            max value in short int is ------>32767.000000
            max value in long int is ------->2147483647.000000
            max value in signed int is ----->32767.000000
            max value in unsigned int is --->65536.000000
            max value in char is ----------->127.000000
            max value in double is --------->9223372036854775810.000000
            max value in float is ---------->2147483647.000000

*/

0 comments:

Post a Comment