+ 4

For decimal values we use which datatype.

Every datatype consist of different type of values like int holds integer values.

29th Jul 2019, 1:25 PM
Naina Bansal
Naina Bansal - avatar
15 Answers
+ 2
You can use float or double
29th Jul 2019, 1:27 PM
Agent_I
Agent_I - avatar
+ 6
Float
29th Jul 2019, 1:48 PM
Naina Bansal
Naina Bansal - avatar
+ 5
Float
29th Jul 2019, 1:33 PM
Autharv Bansal
Autharv Bansal - avatar
+ 2
float using for decimal numbers
30th Jul 2019, 12:47 PM
Vishnu
Vishnu - avatar
+ 1
Don't forget to add f for floating values because either they are initialised with float data type but measured as double. int x = 4;. // result 4 float y = 5.6; ❌ // result 5.6 (but initialised as double) float y = 5.6f; // f is needed here.✔️ double z = 8.9; // Initialized as double correctly. Check that by sizeof(variableName); difference b/w float and double float has 7 point precision means float x = 5.123456789f; cout << x; // result 5.1234567 double has more precise (more accurate) than float means double y = 5.1234567890; cout << y; // result 5.1234567890
29th Jul 2019, 3:58 PM
Piyush Pranjal 🇮🇳
Piyush Pranjal 🇮🇳 - avatar
+ 1
For decimal : use float
29th Jul 2019, 5:09 PM
jack frost
jack frost - avatar
+ 1
You can use float or double For example; float x=2.4; double x=665.678923333;
30th Jul 2019, 4:21 PM
PRAKASH BANDI
PRAKASH BANDI - avatar
+ 1
*Nitrocell I think double always store values as decimal. By your definition we can store integers in float also. double => N.N always Have a nice day. 👍
31st Jul 2019, 3:09 AM
Piyush Pranjal 🇮🇳
Piyush Pranjal 🇮🇳 - avatar
0
Float or double for decimal values
29th Jul 2019, 3:35 PM
Nizamudeen S
Nizamudeen S - avatar
0
Piyush Pranjal 🇮🇳 hey bud, I've mastered C, and C++. I know what I am saying. I read books and from C and C++ float => N.N int => N double => N or N.N
31st Jul 2019, 12:46 AM
Baltazarus
Baltazarus - avatar
0
*Nitrocell Aren't those the same? I mean by definition floating-point, which are both float and double, has the ability to represent real number, or decimal (decimal is actually the wrong term since decimal is a number radix). Mathematically, every integer is real number, so I think something like integer and real number is redundant, and there's no "real number only" since every possible numbers is real number, unless of course something like imaginary number is added to the group
31st Jul 2019, 2:58 AM
Agent_I
Agent_I - avatar
0
Dharmendra Kumar
31st Jul 2019, 3:24 AM
Dharmendra Kumar
Dharmendra Kumar - avatar
0
Piyush Pranjal 🇮🇳 Agent_I guys I know and understand that all. I only want to make example, that will be easy to understand for beginners and others. I learnt that float can store value only with decimal(N.N) number. Int can store integer, and must be without POINT(.). Double can store both of them. So double's value can be N.N or N or N.NNNN. Good luck with coding guys. 👍
31st Jul 2019, 7:23 AM
Baltazarus
Baltazarus - avatar
- 1
float and double float - only decimal value double - decimal and integer
30th Jul 2019, 8:17 AM
Baltazarus
Baltazarus - avatar
- 1
*Nitrocell What ???? Do u know what you're telling.... 🤔🤔🤔
30th Jul 2019, 8:43 AM
Piyush Pranjal 🇮🇳
Piyush Pranjal 🇮🇳 - avatar