Home Forums C Programming Result is only TRUE.

Viewing 1 reply thread
  • Author
    • #2090


      I’m abit of a newbie at C++ programming.
      I’m trying to create a simple program, that can just multiply x and y, that you enter.

      But when I run the program, everything is fine. Then, when I’ve entered the two numbers, the only result that shows up is 1, which must mean that it doesn’t actually retrieve the result, but just says TRUE.

      If anyone would be able to help me with this problem, I’d appreciate it.


      #pragma hdrstop

      using namespace std;
      int multiply (int, int);
      void showResult(int);
      int main(int argc, char **argv);
      int main (int, char**){
      int x, y, result;
      cout<<"Enter the first value:";
      cin>> x;
      cout<<"Enter the second value: ";
      cin>> y;result = multiply(x, y);
      cout<< "Press any key to continue...";
      return 0;

      int multiply(int x, int y){
      return x * y;

      void showResult(int res){
      cout<<"The result is "< }

      Thank you, in advance.

    • #3377

      @Gramdtante wrote:

      void showResult(int res){    
      cout<<"The result is "<<showResult << endl;

      Hello,you are not trying to print the result, as you can see variable res stores the result of the multiplication, but your are printing the result anywhere….You showResult function should look like

      void showResult(int res){
      cout<<"The result is "<<res<< endl;
Viewing 1 reply thread
  • The forum ‘C Programming’ is closed to new topics and replies.