Reputation: 1
I'm new to programming and trying to learn C here. Below is my toy program.
#include <stdlib.h>
#include <stdio.h>
int cmp(int a, int b)
{
if (a > b)
{
return a;
}
else
{
return b;
}
}
int main()
{
cmp(10, 20);
printf("testing...");
return 0;
}
My question is, in the main function, cmp() function is called, and the value 10 and 20 is passed into cmp() function.
In this case, b is larger than a, so it goes to the else branch. b should be returned, which is 20 in this case. Why am I not seeing any outputs on the terminal?
Upvotes: 0
Views: 44
Reputation: 4816
Your function will return an integer value; however, in your "main" function you call your "cmp" function but don't do anything with it. The "printf" function is only instructed to print out "testing..." currently. Here is one possible suggestion for checking the output of your function in the "main" function.
int main()
{
printf("Testing the value of cmp(10, 10) is %d\n", cmp(10, 20));
return 0;
}
Hope that helps.
Regards.
Upvotes: 1