📑C-BASIC📑
C Keyword
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:
The example of declaring the variable is given below:
Here, a, b, c are variables. The int, float, char are the data types.
We can also provide values while declaring the variables as given below:
C Data Types
Data types specify how we enter data into our programs and what type of data we enter.
Following are the examples of some very common data types used in C:
- int: As the name suggests, an int variable is used to store an integer.
- char: The most basic data type in C. It stores a single character and requires a single byte of memory in almost all compilers.
- float: It is used to store decimal numbers (numbers with floating point value) with single precision.
- double: It is used to store decimal numbers (numbers with floating point value) with double precision.
int :-
Integers are whole numbers that can have both zero, positive and negative values but no decimal values. For example,
0, -5, 10
We can use
int for declaring an integer variable.
Here, id is a variable of type integer.
You can declare multiple variables at once in C programming. For example,
float and double :-
float and double are used to hold real numbers.
In C, floating-point numbers can also be represented in exponential. For example,
What's the 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.char :-
Keyword
char is used for declaring character type variables. For example,
The size of the character variable is 1 byte.
short and long :-
If you need to use a large number, you can use a type specifier
long. Here's how:
Here variables a and b can store integer values. And, c can store a floating-point number.
If you are sure, only a small integer (
[−32,767, +32,767] range) will be used, you can use short.signed and unsigned :-
In C,
signed and unsigned are type modifiers. You can alter the data storage of a data type by using them. For example,
Here, the variable x can hold only zero and positive values because we have used the
unsigned modifier.
Considering the size of
int is 4 bytes, variable y can hold values from -231 to 231-1, whereas variable x can hold values from 0 to 232-1.

No comments:
Post a Comment
Please don't comment any spam link in comment.