Questions tagged [return]
The return tag has no usage guidance.
20
questions
0
votes
0answers
26 views
How do I fix my code for PSET 4 blur?
What I tried to do was go to each pixel and see if any neighboring ones existed. If they did, I saved the neighboring pixel's colors. Then I ran a loop to add up all the values in that specific color ...
1
vote
1answer
91 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 ...
0
votes
1answer
44 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. ...
1
vote
1answer
370 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 ...
1
vote
1answer
94 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(...
0
votes
1answer
38 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 ...
0
votes
1answer
23 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 ...
0
votes
2answers
24 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 ...
0
votes
1answer
127 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 ...
0
votes
1answer
9 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.
<#...
0
votes
1answer
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*...
1
vote
3answers
145 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 ...
0
votes
1answer
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 ...
0
votes
1answer
81 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 ...
0
votes
1answer
442 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 ...
0
votes
1answer
283 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 ...
0
votes
0answers
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, ...
0
votes
1answer
91 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 ...
0
votes
1answer
164 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
{
...
1
vote
2answers
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 ? ...