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 main (void) { printf("Please enter the int\n"); //Getting input from user int n = GetInt(); //Used for counting no of iterations int count = 0; //Calling function int ans = coll (n, count); //Printing output of function printf ("%i\n", ans); } int coll (int a,int c) { //Base case returns the value of c if (a==1) { return c; } //If a is even number if (a%2==0) { coll (a/2, c++); } //if a is odd number else { coll ((3*a)+1, c++); } }


You missed one. If the code in the call() function executes the else clause at the end, there's no path to a return statement there.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

  • Yap I have done it by properly returning the values. thanks – Ahmed Raza Nov 18 '16 at 8:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .