Data-types, Keywords and Variables in C || All Data-types in C || C


Welcome Programmers,


In order to excel in any field the very first thing that should be very clear in one's mind is the basics and fundamentals. As we have already done/kickstarted our learning with "Hello World " program in C, now it's time to to start with and clear our basic concepts so that we don't make any minor errors in future due to lack of knowledge.
In this post we will be going to learn about the keywords, variables and datatypes.

Topics to be covered:-
--> What are keywords ?
--> Number of keywords in C.
--> What are Variables ?
--> What is the use of variables ?
--> How to declare Variables in C.
--> What is Data-type ?
--> Type of Data-types and their Size.
--> Use of Datatypes in C.
--> Example Syntax in C.

What are keywords ?

Keyword is a word we use in any programming language which has a specific meaning and perform a particular task. In any Programming Language the definition and meaning of the keyword is same. Keywords can not be used as a variable. Keywords are predefined identifiers that are already in built in the programming language. Keywords are Case-sensitive.

Example:- 
printf, scanf etc. are the keywords of C language.

It is also to be noted that there may be a keyword that is same/used in many languages. example: let's say a keyword 'break' it is used in C, C++, Java, Python too. Take another keyword 'clrscr' it is used in both C as well as C++.

Number of keywords in C.
In this segment we will just give a knowledge about the number of keyword in different languages, so that you are updated and informative about your specific programming language.

In C language we have 32 Keywords.

What are Variables ?

Variable is like a container to store a value of a particular type in a memory location. It is like a identifier in program where the data is labeled and then given to the computer for processing. It can also be said as a medium through which computer gets the information for processing.

There are some predefined rules for variables:
1. Variables should not start with capital letter.
2. Variables should not start with numbers or special characters.
3. Variables should not be repeated.
4. Variables should not be the same as function name.(optional)

What is the use of variables ?

The basic use of variable is to store the information or set of information.
But apart from this it also have some different uses like: it is used to take the input from the user, Many operations can be performed on the variable.

Syntax of declaring a variable in different languages:-


//datatype <space> variable name;
int a;

In C variable value can be assigned either on the line of declaration or after declaration.

What is Data-type ?

It is used to store the data in a particular type. It can also be said that the variable is meaningless without datatype, without datatype there is no use to declare a variable. Datatypes are one of the important factors in the programming language, without Datatype the program may lose some meaning.

Data-types in C


Sr. No. Data Type Specification/Characteristics Range
1. int It is the most used data-type for numbers in any programming language. It takes 32-bit OR 4-bytes memory. -2147483648 to 2147483647
2. long If the int data-type is not enough then we can use long data-type. It takes 64-bit OR 8-bytes memory. -9223372036854776000 to 9223372036854775999
3. __int128_t It is the largest data-type in C/C++ language. It is available in gcc compiler version 4.6 and later only. It takes 128-bit OR 16-bytes memory. -170141183460469231731687303715884105729 to 170141183460469231731687303715884105728
4. float It is the most used data-type for decimal point numbers in any programming language. It takes 32-bit OR 4-bytes memory. -157108198082446589952 to 157108198082446589951
5. double If the type float is not enough for decimal point numbers the we can use double data-type. It takes 64-bit OR 8-bytes memory. -7735413050995762138185728 to 7735413050995762138185727
6. long double It is one of the least used data-type. But the accuracy of long double data-type is more than long type. It takes 96-bit OR 12-bytes memory. -3.4 x 10^4932 to 3.4 x 10^4932
7. char It is a data-type used to store a single character data or string of single byte or letters. It takes 8-bit OR 1-byte memory. -128 to 127
8. void It is a data-type used when a function returns nothing or no-value The value of void is zero.
9. bool It is used to store a value when either its 1(True) or 0(False). It takes 8-bit OR 1-byte memory. True or False
10. short It is used to store short integer values. It takes 16-bit OR 2-bytes memory. -32768 to 32767



Use of Datatypes in C.


C
->In C data type is used to define the type of data. When taking the values from the user, datatype given to the variable decides what type of value should be entered.
->It is also used for declaration of variable.
->It is also defines the size of the variable

Example Syntax in C.

Syntax for data-types and variable in C:
 int b; 
here 'int' is a data-type and 'b' is a variable name.

So in this post we have tried to focus on some basic concepts from next post we will explore more the world of programming.

#ENJOY CODING#

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post