add that takes two int parameters named a and badd should return the sum of a and badd with the numbers 7 and 5add that takes two int parameters named a and badd should return the sum of a and badd with the numbers 7 and 5add function with parametersadd that takes two int parameters called a and b. The function should return an int. Do not write the function body yet.Start by writing the function header int add(int a, int b); and a main function.
add function to return the sumadd function so it returns the sum of the parameters a and b.Use the return statement to send back the sum of a and b.
add function with 7 and 5main function, call the add function with the arguments 7 and 5. Store the result in an int variable named result.Use int result = add(7, 5); inside main to call the function and save the sum.
std::cout statement inside main to print the value of result. Include #include <iostream> at the top of the program.Use std::cout << result << std::endl; to print the sum.
What is the purpose of function parameters in C++?
Which of the following is the correct syntax to declare a function add that takes two int parameters a and b?
type name pairs separated by commas inside parentheses.int a, int b. Options A, B, and C have syntax errors like missing comma, wrong order, or semicolon.What will be the output of the following code?
void greet(std::string name) {
std::cout << "Hello, " << name << "!" << std::endl;
}
int main() {
greet("Alice");
return 0;
}greet takes a string parameter name and prints "Hello, " plus the value of name.main, greet is called with "Alice", so name becomes "Alice".Identify the error in this function declaration:
void printSum(int a, b) {
std::cout << a + b << std::endl;
}b has no type specified.void printSum(int a, int b). Missing type causes a syntax error.Consider this function that calculates the area of a rectangle:
double area(double width, double height) {
return width * height;
}How would you call this function to calculate the area of a rectangle with width 5.0 and height 3.0, and store the result in a variable result?
width first, then height, both as doubles.Pass the test and this pattern moves unknown