+ 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; }
4 ответов
+ 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
+ 2
There is no `short double` type as I understand it. There's `long double` however, maybe you meant to use that one instead.
+ 2
Really?! Ohh, thank you very much, and with what data types can you use "short"?
+ 2
I am very grateful to you!!!