+ 1
Can someone pls tell me the difference betweeb Float,Int,Void,Double .I have no idea when to use one and when the other.
Int Double Void Float,c++
4 Answers
+ 3
int = whole numbers like 1, 2, -10, 1839. 32bit
long = sams as int but using 64bit
float = floating point numbers like 1.73, 3.141, -37.882. 32bit
double = double precision floats, same as float but more accurate. 64bit
void = nothing. literally. only used as return type
+ 2
These all are some types of data. The keyword Int stands for integer number, which does not have any point or any fraction within it. It can be positive or negative. For example, 10, -123, 9999 all of them are integer numbers. So they are declaired as the data type of integer or int. Although short int has a range of -32,768 to 32,767. You can choose any number between the range.
Now float represents a floating point or fractional number. For example, 13.97, -88.0, 0.1 etc. It also has range bound. We can use up-to 6 digits after decimal using float data type.For example, 10.456789 can be stored in a variable using float data type. If you declair 5 as floating point or float then it becomes 5.0 although they are same.
void means no value. This is usually used to specify the type of functions which returns nothing.Â
Now double is a floating-point data type, usually referred to as a double-precision floating-point type. But it has a wide range.
float a=5.2;
float b=2.8;
int c=a+b;
then the result becomes 8 instead of 8.0 as the variable c is declaired as integer.
Hope you understand. :)
Find the range details here ->
https://www.tutorialspoint.com/cprogramming/c_data_types.htm
+ 1
thank u sooo much ,i really appreciate it!!!
+ 1
You are welcome :)