Questions tagged [return]

The tag has no usage guidance.

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

where am i making mistake here? problem set2 substitution

hey here i am trying to return 0 if argument string contains all 26 alphabet characters otherwise function should return 1 and print message]1 ]
Abhi's user avatar
  • 1
0 votes
1 answer
104 views

problem return correct answers

#include <cs50.h> #include <stdio.h> int main(void) { int start, end, years = 0; // Prompt for start size do { start = get_int("Start size: "); } ...
shane's user avatar
  • 3
0 votes
1 answer
38 views

p2 substitution i have no idea how to return multiple value from same variable in a function since c doesnt take variable array length

#include <stdio.h> #include <string.h> #include <math.h> #include <ctype.h> int converter(string plaintext,string text ); int main(int argc, string argv[]) { string code= ...
ibrahim's user avatar
0 votes
1 answer
11 views

Running an 'if' statement inside of a 'for' loop; Need to continue loop w/o printing anything, but not sure what value to return

So, I'm currently working on 'Substitution', and have written the following code to evaluate if a certain array of characters are all alphabetic: for (int i = 0; i < length; i++) { if (isalpha(...
mstack's user avatar
  • 3
0 votes
1 answer
80 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 ...
Max Grossenbacher's user avatar
0 votes
3 answers
29 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 ...
Code Maker's user avatar
1 vote
1 answer
112 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 ...
user9026's user avatar
  • 113
0 votes
1 answer
83 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. ...
Michael's user avatar
1 vote
1 answer
764 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 ...
Nazariy Kushnir's user avatar
1 vote
1 answer
213 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(...
rajat008's 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 ...
Ha Tran's user avatar
  • 74
0 votes
1 answer
29 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 ...
Android1's user avatar
0 votes
2 answers
43 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 ...
Nitish Panda's user avatar
0 votes
1 answer
172 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 ...
Ahmed Raza's user avatar
0 votes
1 answer
14 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. <#...
Ahmed Raza's 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*...
Flesheaters's user avatar
1 vote
3 answers
155 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 ...
Ahmed Raza's user avatar
0 votes
1 answer
125 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 ...
Freya H - MSFT's user avatar
0 votes
1 answer
86 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 ...
Ryan's user avatar
  • 138
0 votes
1 answer
451 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 ...
Bubi's user avatar
  • 88
0 votes
1 answer
297 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 ...
Nilabha Chatterjee's 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, ...
KimPhilby's 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 ...
Alan's user avatar
  • 17
0 votes
1 answer
170 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 { ...
BooFluff's 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 ? ...
Yan Zhang's user avatar