This is a question about language C return.

Asked 2 years ago, Updated 2 years ago, 139 views

int gt(long x, long y)
{
    return x > y;
}

It's a function of what you do How can it be used in the main function?

If x is larger than y... (what?) Return... I don't know what that is (Crying)

c return

2022-09-22 19:26

1 Answers

This return statement returns bullion.

The expression x > y is actually true when x is greater than y, or false. If you want to get the result of that calculation right away, you can write it like that.

If you write that long, it'll look like this.

int gt(long x, long y)
{
  if (x > y) {
    return true;
  } } else {
    return false;
  }
}

But because it's more readable (not only grammatically the same) than writing it like this ("Ah, you're comparing the two numbers now to determine whether they're large or small!"), it's advantageous to write it like above.


2022-09-22 19:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.