Questions tagged [return]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
12 views

Function returns not working for CS50 readability.c

In CS50 we now have to make multiple functions (I guess they want us to get used to objective-oriented programming for the python part later) and return the value to the main function. When I execute ...
user avatar
0 votes
3 answers
19 views

Error retrieving return values ​from a function

I am currently studying coding in C language and I have doubts about the return of functions, what I am trying to do is the following: Call the number () function and pass 3 values ​​of the integer ...
user avatar
1 vote
1 answer
100 views

Return type of printf in C

In the video Data Types, Doug says around 6:50 that printf does not have a return value. I don't think this is true. printf does return the number of character printed on the screen. Here is a ...
user avatar
  • 113
0 votes
1 answer
70 views

Why do i need a return value when my program will recurse until it does in fact return a value?

To fix this problem all i need to do is return something in the else part of the if statement, but it seems so pointless and messy because the program is designed to recurse until a value is returned. ...
user avatar
1 vote
1 answer
581 views

End program by returning exit code 0 from bool function

so, for pset2 crack task i've generate a password, then encrypt this password and a salt to some result by result = crypt(pass, salt); After i want to compare result with hash, so i implemented a ...
user avatar
1 vote
1 answer
153 views

What should the return type of swap function be?

#include<stdio.h> #include<cs50.h> void swap(int x,int y); int main(void) { int x=get_int(),y=get_int(); printf("1=%i and 2=%i",x,y); swap(x,y); printf("1=%i and 2=%i",x,y); } void swap(...
user avatar
0 votes
1 answer
41 views

pset 3 won() function always return false

I'm stuck on the logic in pset3 won() function. Apparently, the function just doesn't return true no matter what. Here is my code. bool won(void) { int n = 1; //iterate over the board for ...
user avatar
  • 74
0 votes
1 answer
26 views

C : error non-void function search - value (find)

I'm getting error non-void function search should return a value. If I add anything else to last return, such as false 1 or zero, the errors multiply. I've tried moving the indentations as well as ...
user avatar
0 votes
2 answers
27 views

Will the loop break in case the condition returns some value to the caller method in C?

If i write the following: for(int i=0; i<=1000; i++) { if(arr[1] == n){ return true; } } Will the loop break when the condition holds true and the return statement returns the value to the ...
user avatar
0 votes
1 answer
150 views

I implemented Collatz recursion which is giving error "Control reached at non void function"

It has proper return value kindly guide me how can i tell compiler I have return values. here is the code #include <stdio.h> include <cs50.h> int coll (int a,int c); int ...
user avatar
0 votes
1 answer
11 views

This is the code why it is not returning the swapped values

This code is written to return swapped values, why values are not being returned, My basic question is how can i take return value from function called, please demonstrate with any code example. <#...
user avatar
0 votes
1 answer
49 views

pset3 won function - Where does the "return true;" statement go?

bool won(void) { int counter = 1; for (int i = 0; i < d; i++) { for (int j = 0; j< d; j++) { while (board[i][j] != board[d-1][d-1] && counter != d*...
user avatar
1 vote
3 answers
154 views

This code of triangle problem always give me "true".I can,t find bug in this please find the bug

#include <cs50.h> #include <stdio.h> bool triangle (float a, float b, float c); //Declaration of function int main (void) { printf ("Give me three sides of ...
user avatar
0 votes
1 answer
119 views

PSet3 Find passing my testing but failing check50

I'm working on linear search. When I test manually, it works correctly, and "echo $?" will show a 0 and 1 as expected. I have tried it with piped-in data sets, with the 127 and 128 examples from the ...
user avatar
0 votes
1 answer
84 views

Recursive Binary Search Exit Code Errors

I wrote the following recursive binary search function. No matter which exit codes I use (e.g., true, false, 1, 0, -1, "Swedish Chef"), I fail at least two of the checks I need to pass. The code ...
user avatar
  • 138
0 votes
1 answer
445 views

Pset5 - Apostrophe and check problems with Tries

Alright, so I have spent days with with load, and just recently implemented check. I've read upon stuff, rewatched videos, all the good stuff. I'm trying to do pset5 (misspellings) with Tries. I ...
user avatar
  • 88
0 votes
1 answer
294 views

caesar argc ... help me get started

Ok so i just started caesar and i don't know whether I'm headed in the right direction or not, if not i just need someone to point me the right way,and yes i have seen the walkthrough. so heres my ...
user avatar
0 votes
0 answers
39 views

Cannot get both ball and paddle to work at the same time

Breakout: If I put return ball inside the while loop, I get a working paddle but the ball doesn't move. If instead, I put return ball outside the while loop or have no return at all, the ball moves, ...
user avatar
0 votes
1 answer
92 views

pset3 return function

When I tried to return newGRect instead of rect in this case and compiled my whole program, I got the message of Segmentation fault. May I know why? Also, may someone tell me where to find a ...
user avatar
  • 17
0 votes
1 answer
169 views

pset3 helpers.c not working

this is my code for the top part { for (int i = 0; i < n; i++) { if (values[i] == value) { return true; } else { ...
user avatar
1 vote
2 answers
4k views

Pset3 Binary Search problems

I have tested the code presented in the picture and find this function always returns false no matter what number you search.There must be a problem in it but I can not see it!! Can anyone help me ? ...
user avatar