Can i solve this question without using reference variable c.
I mean i want to return the answer from the function or give any other alterntive way
Alternative method
@KetanPandey you will have to return a pair of <bool, int> if you want to return 2 values, but yes that can be done. you can return {true, 1} when you successfully place all queens in the base case, and add that value to a pre-existing count variable in the function. keep updating that variable throughout the function (if false value is returned, return <false, 0> so you can add 0 to count, else add 1) and in the end, return <bool ans, int count> so that its value can be passed to consecutive calls.
I have made needed changes in your code, have a look https://ide.codingblocks.com/s/268595
Please mark your doubt as resolved in case of no further queries.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.