Primary data types of programming could be of three varieties—char, int, and float. We can derive many data types from these three types.
A char could be an unsigned char or a signed char. Or an int could be a short int or a long int.
Integers, long and short We had seen earlier that the range of an Integer constant depends upon the compiler.
For a 16-bit compiler like Turbo C or Turbo C++ the range is –32768 to 32767.
For a 32-bit compiler the range would be –2147483648 to +2147483647.
16-bit compiler means that when it compiles a C program it generates machine language code that is targeted towards working on a 16-bit microprocessor like Intel 8086/8088.
A 32-bit compiler like VC++ generates machine language code that is targeted towards a 32-bit microprocessor like Intel Pentium.
A program compiled using Turbo C would not work on 32-bit processor. It would run successfully but at that time the 32-bit processor would work as if it were a 16-bit processor.
This happens because a 32-bit processor provides support for programs compiled using 16-bit compilers. If this backward compatibility support is not provided the 16-bit program would not run on it.
Out of the two or four bytes used to store an integer, the highest bit (16th/32nd bit) is used to store the sign of the integer. This bit is 1 if the number is negative, and 0 if the number is positive.
C offers a variation of the integer data type that provides what are called short and long integer values.
Short and long integers would usually occupy two and four bytes respectively. Each compiler can decide appropriate sizes depending on the operating system and hardware for which it is being written, subject to the following rules:
Long integers cause the program to run a bit slower, but the range of values that we can use is expanded tremendously. The value of a long integer typically can vary from -2147483648 to +2147483647.
Integers that need less space in memory and thus help speed up program execution.
Short integer variables are declared as,
short int j ;
short int height ;
C allows the abbreviation of short int to short and of long int to long. So the declarations made above can be written as,
long i ;
long abc ;
short j ;
short height ;
OTHER PROGRAMMING COURSES:
INTRODUCTION TO C PROGRAMMING
Programming with C an introduction part two
Data types for C programming
C PROGRAMMING CHARACTER SET
CONSTANTS IN C PROGRAMMING
PROGRAMMING C VARIABLES
C PROGRAM INSTRUCTIONS
COMPILATION AND EXECUTION OF C PROGRAM
C PROGRAMMING RULES PART ONE
C PROGRAMMING RULES PART TWO
COMPILATION AND EXECUTION OF C PROGRAM
INSTRUCTIONS TO WRITE C PROGRAM
ARITHMETIC INSTRUCTIONS TO WRITE C PROGRAM
CONVERSION OF CONSTANTS IN C PROGRAM
PRIORITY OF AR THEMATIC OPERATIONS IN C
OPERATORS ASSOCIATIVITY IN C
IF STATEMENT
MULTIPLE STATEMENTS IN IF
IF AND ELSE
NESTED IF AND ELSE
BREAK
CONTINUE AND DO WHILE IN C LANGUAGE
SWITCH IN C PROGRAMMING
FUNCTIONS IN C PROGRAMMING
Functions and usage in C part two
Coding in C functions
A char could be an unsigned char or a signed char. Or an int could be a short int or a long int.
Integers, long and short We had seen earlier that the range of an Integer constant depends upon the compiler.
For a 16-bit compiler like Turbo C or Turbo C++ the range is –32768 to 32767.
For a 32-bit compiler the range would be –2147483648 to +2147483647.
16-bit compiler means that when it compiles a C program it generates machine language code that is targeted towards working on a 16-bit microprocessor like Intel 8086/8088.
A 32-bit compiler like VC++ generates machine language code that is targeted towards a 32-bit microprocessor like Intel Pentium.
A program compiled using Turbo C would not work on 32-bit processor. It would run successfully but at that time the 32-bit processor would work as if it were a 16-bit processor.
This happens because a 32-bit processor provides support for programs compiled using 16-bit compilers. If this backward compatibility support is not provided the 16-bit program would not run on it.
Out of the two or four bytes used to store an integer, the highest bit (16th/32nd bit) is used to store the sign of the integer. This bit is 1 if the number is negative, and 0 if the number is positive.
C offers a variation of the integer data type that provides what are called short and long integer values.
Short and long integers would usually occupy two and four bytes respectively. Each compiler can decide appropriate sizes depending on the operating system and hardware for which it is being written, subject to the following rules:
- shorts are at least 2 bytes big
- longs are at least 4 bytes big
- shorts are never bigger than ints
- ints are never bigger than longs
Long integers cause the program to run a bit slower, but the range of values that we can use is expanded tremendously. The value of a long integer typically can vary from -2147483648 to +2147483647.
Integers that need less space in memory and thus help speed up program execution.
Short integer variables are declared as,
short int j ;
short int height ;
C allows the abbreviation of short int to short and of long int to long. So the declarations made above can be written as,
long i ;
long abc ;
short j ;
short height ;
OTHER PROGRAMMING COURSES:
INTRODUCTION TO C PROGRAMMING
Programming with C an introduction part two
Data types for C programming
C PROGRAMMING CHARACTER SET
CONSTANTS IN C PROGRAMMING
PROGRAMMING C VARIABLES
C PROGRAM INSTRUCTIONS
COMPILATION AND EXECUTION OF C PROGRAM
C PROGRAMMING RULES PART ONE
C PROGRAMMING RULES PART TWO
COMPILATION AND EXECUTION OF C PROGRAM
INSTRUCTIONS TO WRITE C PROGRAM
ARITHMETIC INSTRUCTIONS TO WRITE C PROGRAM
CONVERSION OF CONSTANTS IN C PROGRAM
PRIORITY OF AR THEMATIC OPERATIONS IN C
OPERATORS ASSOCIATIVITY IN C
IF STATEMENT
MULTIPLE STATEMENTS IN IF
IF AND ELSE
NESTED IF AND ELSE
BREAK
CONTINUE AND DO WHILE IN C LANGUAGE
SWITCH IN C PROGRAMMING
FUNCTIONS IN C PROGRAMMING
Functions and usage in C part two
Coding in C functions
No comments:
Post a Comment