C Identifiers
Identifier refers to name given to entities such as variables, functions, structures etc.
Identifier must be unique. They are created to give unique name to a entity to identify it during the execution of the program.
int money; double accountBalance;
Here, money and accountBalance are identifiers.
C Keywords
Keywords are predefined, reserved words used in programming that have special meanings to the compiler. Keywords are part of the syntax and they cannot be used as an identifier. For example:
int money;
C Programming Data Types
In C programming, variables or memory locations should be declared before it can be used. Similarly, a function also needs to be declared before use.
Data types in C
- Fundamental Data Types
- Derived Data Types
int - Integer data types
Integers are whole numbers that can have both positive and negative values but no decimal values. Example: 0, -5, 10
In C programming, keyword int is used for declaring integer variable. For example:
int id;
Here, id is a variable of type integer.
You can declare multiple variable at once in C programming. For example:
int id, age;
float - Floating types
Floating type variables can hold real numbers such as: 2.34, -9.382, 5.0 etc. You can declare a floating point variable in C by using either float or double keyword. For example:
float accountBalance; double bookPrice;
Here, both accountBalance and bookPrice are floating type variables.
In C, floating values can be represented in exponential form as well. For example:
float normalizationFactor = 22.442e2;
Difference between float and double
The size of float (single precision float data type) is 4 bytes. And the size of double (double precision float data type) is 8 bytes. Floating point variables has a precision of 6 digits whereas the precision of double is 14 digits.
char - Character types
Keyword char is used for declaring character type variables. For example:
char test = 'h';
Here, test is a character variable. The value of test is 'h'.
The size of character variable is 1 byte.
Size qualifiers
Size qualifiers alters the size of a basic type. There are two size qualifiers, longand short. For example:
long double i;
The size of double is 8 bytes. However, when long keyword is used, that variable becomes 10 bytes.There is another keyword short which can be used if you previously know the value of a variable will always be a small number.
Sign qualifiers
Integers and floating point variables can hold both negative and positive values. However, if a variable needs to hold positive value only, unsigned data types are used. For example:
// unsigned variables cannot hold negative value unsigned int positiveInteger;
There is another qualifier signed which can hold both negative and positive only. However, it is not necessary to define variable signed since a variable is signed by default.
An integer variable of 4 bytes can hold data from -231 to 231-1. However, if the variable is defined as unsigned, it can hold data from 0 to 232-1.
It is important to note that, sign qualifiers can be applied to int and char types only.
Sloty Casino - Mapyro
ReplyDeleteSloty Casino has 보령 출장마사지 over 700 광명 출장샵 games and offers a wide range of promotions for new players. 원주 출장샵 We have a list 파주 출장안마 of all the slots and 과천 출장샵 bonuses to keep you coming back