First off, return isn't a function, so you don't do return(SUM);It's just return SUM;Then you need a call to that function after the inputs: float sum = SUM(a,b,c,d,e);Also, you're missing an ending curly brace at the end of main
That's odd. My lecture notes say to have parentheses around the return variable. There's even parentheses on it on the example code snippets. And yeah I know I'm missing a brace. I tried removing it thinking the main function had to be wrapped around the sum function. So how exactly would I continue with the main function after returning? Do I put the code in the first main function brackets or start a new main function after the sum function(talking about the part where the average is calculated and output to the user)?
#include <stuff>using namespace std;float SUM(float a, float b, float c, float d, float e){ return a + b + c + d + e;}int main(void){ // Your code defining values and collecting their data float answer = SUM(a, b, c, d, e); cout << "The answer is " << float << endl;}
That's odd. My lecture notes say to have parentheses around the return variable. There's even parentheses on it on the example code snippets.
I guess parenthesis are usually allowed and usually works. But it's not really standard, and not required. Probably better not to, as some IDEs/compilers/languages may not allow it
anyone know how to disable the auto formatting in visual studio? i bought it today
Nowadays I'll only use them if I need to cast my math into the return type.
why?return 1 + 1 will work just as well as return(1 + 1)I don't really care what you use, but you should keep it consistent...
/// <summary> /// Returns a single Float value based on Inspector-style values. Minimum value is "0" and maximum value is "255". /// </summary> /// <param name="s">The single number to convert.</param> /// <returns></returns> public static float ConvertInspectorColours(int s) { return (float)s / 255.0f; }
You didn't actually use the SUM function anywhere, though?