C Numeric Variable Types Integer, Long, Float

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/c-numeric-variable-types-integer-long-float/
PINTEREST
PINTEREST
INSTAGRAM

C Programming Tutorial Index

  1. Introduction To Programming
  2. C Setup Development Environment
  3. C Hello World and Compile First Application
  4. C Syntax and Basics
  5. C Variables
  6. C Numeric Variable Types (Integer, Long, Float)
  7. C String Variables
  8. C Constants and Define Processor
  9. C Operators
  10. C If Else and Switch Case Conditionals
  11. C While Loops
  12. C For Loops
  13. C Arrays
  14. C Functions
  15. C Structure
  16. C Union
  17. C File Operations (Open, Read, Write)
  18. C Pointers
  19. C Type Casting
  20. C Header Files and Include

As we learn variables are used to store values and variables have type. Type provides information about the value hold in the variable. Numeric types used to hold numerical data like 3 , 3.5 , 23.354354646 etc. Numerical types provides simplicity and performance while making mathematical operations. There are 5 different numerical types. Here we go

Integer

Integers are normal counting numbers. To specify a variable type as integer we use int before variable name. Integer variables require generally 4 byte memory to hold data. Integer variables can hold values between-2,147,483,648 to 2,147,483,647 . Here is some example about integer.

Here we have created an integer variable named age which holds value 25

Short

Short type is used variable those will hold lower  numbers versus integer. Short type specifier is same with the type name as short . Short variables require 2 byte to hold in memory. Short number range  is between -32,768 and 32,767 .

We have created a short type variable named length with value 180

Long

Long is used to hold more than integer values long requires 4 byte for memory and holds between -2,147,483,648 to 2,147,483,647 .

Variable named total holds value 12314235345 which is a long type.

LEARN MORE  Python Variables and Types

Float

Float variable type is different from above variable types because above types used only counting numbers. If we want to use floating numbers float is the type we will use. Here is some floating number examples 1.0 , 123.345345, 34355.54 etc. Float variables requires 4 byte memory and hold values between 1.2E-38 to 3.4E+38 which is equal 6 decimal places.

Variable named percentage holds 123.123 which’s type is float.

Double

Double is similar to the float type but double have double capacity according to  float. so double variables will use 8 byte memory and will hold values between. 2.3E-308 to 1.7E+308 which is equivalent 15 decimal places.

Variable named percentage holds 123.123 which’s type is double.

Float vs Double

Float and double variables types both hold float numbers. Why shouldn’t we use all ways double to make development more easy and less error prone? Because double requires more memory and using all ways double variables will be a bad practice for memory management.

C Programming Tutorial Index

  1. Introduction To Programming
  2. C Setup Development Environment
  3. C Hello World and Compile First Application
  4. C Syntax and Basics
  5. C Variables
  6. C Numeric Variable Types (Integer, Long, Float)
  7. C String Variables
  8. C Constants and Define Processor
  9. C Operators
  10. C If Else and Switch Case Conditionals
  11. C While Loops
  12. C For Loops
  13. C Arrays
  14. C Functions
  15. C Structure
  16. C Union
  17. C File Operations (Open, Read, Write)
  18. C Pointers
  19. C Type Casting
  20. C Header Files and Include
RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/c-numeric-variable-types-integer-long-float/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)