Type of Variable In C Programming.

Type of Variable In C Programming.

Type of variable in C programming.

If you are learning the C programming language for the first time. So you must know about C Programming Variables and Variable Declaration. Variables are declared first in any C program. Every C language variable stores a specific value in the C program. Here your declared C program variable can be Integer, Float, Character, String, Double, Long Double, etc. Whenever any type of calculation and process of any programmed value is done in C language, then that value is stored and processed in the form of the C program value. You cannot process and calculate any C program data without program variables.

Variable in c programming.

Variable is any C program storage location associated with declared data type nature variable type. In simple language, the variable is the process value holder in the program. The value container store in every program declares the data type variable value store as a folder. It is not possible to store and process values ​​in C programming without the declaration of program variables. Multiple C data types are of variable nature classified. That means, that when you declare an integer variable, it stores the full integer data type value. Float variable stores with float points also store the same decimal value as the floating precision number. Similarly, you store and process text in a single character and array string format in character data type.

Rule of variable declaration.

  • The name of any program variable must be at least 255 characters long.
  • Always declare variables with lower case in C programs. Because c is case-sensitive programming.
  • _ underscore With this, you can separate large variables.
  • Always any variable name should be short or full meaning.
  • You can declare the variable as per the requirement in C program before or after.
  • Remember it is always a better programming practice to declare any program variable before using it.

Identifiers in c programming.

An identifier is a name for any program variable. The variable declared as the identifier in the C program will always have the same name, it can never be repeated in the program. In any program, identifiers identify variables as objects. Variable storage is the type of identifier used to declare the memory location.

Data type in c programming.

Integer Variable declaration.

Integer data type – Integer data type stores whole number/numeric value No decimal part is added. The int keyword is the integer data type in memory reserved for storing integer type variables/identifiers, and the default storage size of the integer data type is 2 bytes. In the C program integer, any data type storage range is between -32768 to + 32767.

Integer Variable DeclarationDescription
Int a;Declare integer variable with the name a
Int a; int b;Two separate integer variable declaration
Int a, b, c;Three combined integer variable declaration
Int a=3, b=5, c;Declare two integer variable provide initial value to a and b, but c input manual value
Int n, float p;Two different data type declare name, variable n contain integer value but variable p contain a floating value in memory

Character Variable declaration.

Character data type – In the C program if you want to process a string with a single character, text, or array. So you have to declare the character type variable. The character data type stores 1 byte in computer memory by default. And its range is between -128 to 127.

Character Variable DeclarationDescription
Char x;Declare single character x variable declaration
char p=’q’;Declare char p variable, here store p q character value
Char name [10];Declare character as string, with 10 array subscript. It holds 10 character in memory
Char name[ ]={‘c’,’o’,’m’,’p’,’u’,’t’,’e’,’r’};Declare empty arrays of subscript, fix character sets store name character string variable
Char a=5;Illegal character variable declaration example

Float Variable declaration.

Float data type – In the past, we have learned that if you have to store or process a decimal number with an integer value in a C program. So you will need a floating data type declaration. You will be able to store and process floating numbers in the float data type. By default float in the C program stores 4 bytes in the computer. And its data storage range is between 3.4E-38 to 3.4E+38.

Floating Variable DeclarationDescription
Float m;Declare floating m name variable
Float m, n;Declare two individual float variable number
Float a=3.2, float b=3.2, float c=7.8;Declare three floating numbers with initial values provided
Float rent; Rent=700.40;Declare variable name rent, initialize the value to rent
Float height=5.6; float width=9.8;Declare two float separate declaration with initial value declare
Float avg[ 5]={20.25,30.40,50.30,60.65,70.80};Declare float variable name avg, store 5 student average continuously

Double Variable declaration.

Double data type – Double data type stores values ​​in computer memory 3 times more than integer data type and 2 times more than float data type. If you want to store a large number format value. Sometimes you have to process large integer number values. There you process double-type data. By default double data type C program stores 8 bytes in the computer. And its store data range is between -922337203685475808 to 922337203685475807.

Double Variable DeclarationDescription
Double x;Declare variable name double x
Double price; price=568214;Declare double variable name price, assign price storage value
Double principle=60000, amount=100000;Two double variables declare and assign individual values to them

Long double variable declaration.

Long Double data type – The long double data type is also a double data type of double. This data type is not used by ordinary programmers. This type of data type is used to create large applications, operating system core, kernel code, etc. The long double data type holds 16 bytes of memory space in the computer.

Double Variable declarationDescription
Long double x, y;Declare two separate long double x and y variable
Long double p=1125455;Declare long double variable p and provide them fixed value
Double =455455; Long double amount=12456747;Declare double variable
Declare long double variable with name amount and provide them fixed integer value
Rate this post

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top