Tags "return" Result

What exactly does a return statement do in C#?

It's hard for me to grasp what exactly a return statement is doing. For instance, in this method... public int GivePoints(int amount) { Points -= amount; return amount; } Even if I place any random integer after return, the GivePoints method still does the exact same thing. So what is it that the return statement is d

it1352 3 2019-05-10

C "return" without value

What is the meaning if there is no value of return? Thanks void run_algo() { ... project(tolabel->second); ... } void project(Projected &projected) { unsigned int sup = support(projected); if(sup < minsup) // minsup is a global variable return; ... } Solution Since the type of your function is void, whe

it1352 0 2019-05-13

What does it mean to return a value?

I'm fairly new to programming, and I'm confused about what it means exactly to return a value. At first, I thought it meant to output what value is being returned, but when I tried that in my own code, nothing happened. class Class1 { public static int x = 3; public static int getX(){ return x; } public static void main

it1352 1 2019-05-21

Return address of local variable in C

Say I have the following two functions: 1 int * foo() { int b=8; int * temp=&b; return temp; } 2 int * foo() { int b=8; return &b; } I don't get any warning for the first one (e.g. function returns address of a local variable) but I know this is illegal since b disappears from the stack and we are left with a pointer to u

it1352 1 2019-05-09

Return an exit code without closing shell

I'd like to return an exit code from a BASH script that is called within another script, but could also be called directly. It roughly looks like this: #!/bin/bash dq2-get $1 if [ $? -ne 0 ]; then echo "ERROR: ..." # EXIT HERE fi # extract, do some stuff # ... Now in the line EXIT HERE the script should exit and return exit code 1. The probl

it1352 2 2019-05-09

Returning Value in C

I have a problem with the return value in a binary search that I wrote. I have the following: int binarySearch(char *instructions[], int low, int high, char *string); int main() { char *instructions[]; // some array of strings - it does not include the string "jk" char *string = "jk"; int high = inst_len; int x = binarySearch(in

it1352 0 2019-05-10

Differences between System.out.println() and return in Java

I'm trying to understand the difference, and benefits of using System.out.println() vs. return blah in a method. It seems like System.out.println() is used to display static information, and return is a value returned from the method. Yet I'm seeing examples like the one below, where a function is used within the System.out.println() statement Sy

it1352 0 2019-05-21