Key Concepts

Review core concepts you need to learn to master this subject

Return Values

#include <iostream> int sum(int a, int b); int main() { int r = sum(10, 20); std::cout << r; } int sum(int a, int b) { return(a + b); }

A function that returns a value must have a return statement. The data type of the return value also must match the method’s declared return type.

On the other hand, a void function (one that does not return anything) does not require a return statement.

Lesson 1 of 3

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo