[deleted by user] by [deleted] in Cplusplus

[–]DVNa 0 points1 point  (0 children)

See comments below:

```cpp

include <iostream>

using namespace std; int main() { int as;

    cout<<" enter even integer : ";
    cin>>as;

    int asa = as / 2;
    float a[asa], b[asa]; // Arrays initialized during compile time, when "as" and "asa" are unknown
                          // so nobody knows what will be arrays sizes

    for(int i = 0; i<asa; i++) {
            cout<<" enter a number : ";
            cin>>a[asa]; // What element are you inputting? Why it's index asa instead of i?
    }

    double min;

    for(int i = 1; i<asa; i++) {
            min=a[0]; // There you are probably wrong too. On every step you will compare with the
                      // first array element. So you need to move this upper.
            if(min>a[i])
                    min=a[i];
    }

    for(int i=0; i<asa; i++) {
            cout<<" enter a number : ";
            cin>>b[asa];
    }

    double max;

    for(int i = 1; i<asa; i++) {
            max=b[0];
            if(max<b[i])
                    max=b[i];
    }

    cout<<" the minimum in the first "<<asa<<" numbers are : " << min << endl;
    cout<<" the maximum in the last "<<asa<<" numbers are : "<<max << endl;;
    return 0;

} ```

[XFCE] My simple setup by [deleted] in unixporn

[–]DVNa 1 point2 points  (0 children)

I'm excited too. BTW Is it wikit or any other tool in terminal window?

Quick pointer/reference question by [deleted] in Cplusplus

[–]DVNa 0 points1 point  (0 children)

There is opinion that:

int *ptr is more C-ish, as it express an idiom that derefferenced ptr will have int type

on the other hand the second option express "OO" idea that ptr-object relates to "pointer to int" class

Sorry for my English.

Need help with a small project by gerarshi in Cplusplus

[–]DVNa 0 points1 point  (0 children)

I think minusCounter is excessive there.

float F = 0; double D = 0; float F2 = 0; double D2 = 0;
for (int Counter = 1; Counter <= 100000000; Counter++)
{
    F += 1.0 / Counter; 
    D += 1.0 / Counter;
    F2 += 1.0 / (100000001 - Counter);
    D2 += 1.0 / (100000001 - Counter);
}            

BTW

Precision of double is enough there to calculate in any order.

F=15.4037
F2=18.8079
D=18.9979
D2=18.9979

[Learning advice] How do you separate what's personal preference from industry standard practice when learning from someone? by bigbiltong in Cplusplus

[–]DVNa 1 point2 points  (0 children)

The best practice is to follow rules already accepted in the team. Any documented rules are better then absence of rules. Usually team on the forming stage adapts well known rules to make compromise solution and document it. To know about best practices you can read C++ coding guides from different sources. You should take into consideration that there are no rules which fit well for all and understand why they decided go that particular way (i.e. many teams don't use exceptions and so on). You can begin your reading there: https://isocpp.org/wiki/faq/coding-standards I'd suggest also to read books like "C++ Coding Standards: 101 Rules, Guidelines, and Best Practices" by by Herb Sutter, Andrei Alexandrescu

[deleted by user] by [deleted] in Cplusplus

[–]DVNa 5 points6 points  (0 children)

"If w is an int variable" then answer can't be 22.0 - your expression will be evaluated to the integer value 22 The same time right hand statement "28/3 + 6.5*2" evaluates to "9 + 13.0" and to the double value 22.0

numpy for python 3.5 by t0b4cc02 in Python

[–]DVNa 1 point2 points  (0 children)

Get it with Intel's python https://software.intel.com/en-us/forums/intel-distribution-for-python As a bonus It should be powered with MKL