Q:

Indicate which of the following functions are in error and why. Suggest how you might correct the problems

0

Indicate which of the following functions are in error and why. Suggest how you might correct the problems.

(a)

int f() { string s; // ... return s;
}

(b)

f2(int i) { /* ... */ }

(c)

int calc(int v1, int v1) /* ... */ }

(d)

double square(double x) return x * x;

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

(a)

    //int f() {  // Return type doesn't match
    string f() {
      string s;
      // ...
      return s;
    }

(b)

    //f2(int i) { /* ... */ }  // Must have a return type
    void f2(int i) { /* ... */ }

(c)

    //int calc(int v1, int v1) /* ... */ }  // Forget begin brace `{`, and no two paramaters can have the same name.
    int calc(int v1, int v2) { /* ... */ }

(d)

    //double square(double x) return x * x;  // The function body should be a block.
    double square(double x) { return x * x; }

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now