Hello,
I've been studying function calling lately. I've written a program to ask for two variables, b and c, from the User, calculate res (resistance), and print the variable res.
I've changed the structure two times, trying to simplify the program so that I can understand the subject of function calling. At one point I had three functions being called from the main function: getVariables, calculate and printOne. Although I was able to build the program without any failures, the variable res was being printed as 0.000000. So, I simplified and kept only the function calculate, and programed the variable res to be printed from the main function. No change. The program still prints 0.000000 for the variable res.
I read through the Howtos of posting. It is stated that I should not post homework. I can't help it. I really enjoy programing at this point, and I really want to know what it is (or what they are) I am not understanding about this program and the output I am receiving versus the output I desire.
Any help is greatly appreciated. If my lesson lies outside of function calling, please let me know. I do want to learn C++. Thanks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

Assume that all variables are defined as double.
Note that the program should ask the user to enter the values for the variables b and c
and the program computes and displays the value for the variable res."
*/
#include <stdio.h>
//Function Declarations
double calculate (double b, double c);
int main (void)
{
//Local Declarations
double b;
double c;
double res;
//Statements
printf("\nPlease enter the values for b and c:");
scanf_s("%f %f", &b, &c);
res = calculate(b, c);
printf("\nRes is %f:\n", res);
return 0;
} // main
/*=====calculate=====
This function calculates the formula res using the variable values given by the User for variables b and c.
*/
double calculate (double b, double c)
{
//Local Declarations
double res;
double sum;
double product;
//Statements
sum = b + c;
product = b * c;
res = sum / (2 * product);
return res;
} //calculate
 