For loop not working in a C++ method


#1

I am preparing for a technical assessment by a company using condingame as the platform. The tutorial asks to write the method of class (C++) to check if a number is present in an array. In the method whenever I use: for(int i=0;i<size;i++) it gives an error saying the program is not returning anything. I even tried simple stuff like for (int i=0;i<5;i++) {return true;} but still not working! any idea!


#2

You probably want some kind of if statement


#3

Don’t return, use cout to write to console, or printf or whatever.
Answers are read from console not return.


#4

For a real technical assessment, i believe the wanted response is using count_if.


#5

what is the real task description?
probably u didnt understand conditions.
how u receive array?
how u should return result?

at CodinGame u get the data from stdin(C scanf, C++ cin) and should print results to stdout(C printf, C++ cout).
stderr(C++ cerr) used for logging/debugging - u can print to the one anything what u want, CG ignoring it.