+ 1

# Why short double doesn't work?

// Π½Π°ΡΠΎΠ΄ΠΈΡ ΡΡΠΌΠΌΡ Π²ΡΠ΅Ρ ΠΏΠΎΠ»ΠΎΠΆΠΈΡΠ΅Π»ΡΠ½ΡΡ ΡΠΈΡΠ΅Π» ΠΌΠ°ΡΡΠΈΠ²Π° #include <iostream> #include <cmath> using namespace std; int main() { int n = 6, i=0; short double sum =0; // the compiler swears at this line double arr[n] = {2.3, -4, 6, 7, 1.23, 14}; // ΠΏΠ΅ΡΠ΅Π±ΠΈΡΠ°Π΅Ρ ΡΠ»Π΅ΠΌΠ΅Π½ΡΡ ΠΌΠ°ΡΡΠΈΠ²Π° while (i < n){ if (arr[i] > 0) sum+=arr[i]; i++; } cout <<"Sum of positive numbers = "<< sum << endl; return 0; }

22nd Jan 2021, 2:42 PM
Aibek Zhaisanbay
+ 4
`short` is one of the type modifiers in C/C++ that changes the related type storage space & data range. As I understand it, `short` is only applicable to integer type (`double` is floating point type). For more info about modifiers, please refer the following link https://www.techcrashcourse.com/2015/11/modifiers-in-c-constants-data-types-c.html
22nd Jan 2021, 3:12 PM
Ipang
+ 2
There is no `short double` type as I understand it. There's `long double` however, maybe you meant to use that one instead.
22nd Jan 2021, 2:59 PM
Ipang
+ 2
Really?! Ohh, thank you very much, and with what data types can you use "short"?
22nd Jan 2021, 3:05 PM
Aibek Zhaisanbay
+ 2
I am very grateful to you!!!
22nd Jan 2021, 3:35 PM
Aibek Zhaisanbay