"int" in C language |Use of "int" in C|
Do we need to use integer data type in "C" even if we don't need it?
Answer:
-
No, integer data type is a type widely used in C and other
programming languages. we use a generally a data type to declare any variable
For Example: int a,b;
-
From the above example you can see "int" which represents "integer datatype", and "a", "b"
are two variables that are declared in integer type.
-
Integer data type generally takes 16,32,64 bits of space depending on the machine . Integer data type is used to represent integer values ("23").
-
There are also other data types like "float data type", "char", "string", "boolean" etc.,
-
If you don't need integer data type in your program you can skip using
it.
-
But remember without declaring the variable in any data type(like
float, int, char, string) you can't run the program.
-
Like if you want to display a float value
then you can declare the variable in float data type.
-
But declaring a variable is very important in programming.
Example program:
#include <stdio.h>
int main()
{
printf("Hello World");
return 0;
}
Explanation:
If you see in this program there in no declaration in it . So, it doesn't
mean that the program is wrong it is correct, it is just going to print so
it doesn't need any declaration further.
Comments
Post a Comment