This problem can be solved using call by reference method, see the following sample function -
void returnvaluewithoutreturnkeyword(int *a) { *a=5; }
simple just send address
#include <stdio.h> void initialize(int *nmb) /* here you are entering variable in main trouth pointer */ { *nmb = 5; /* if we print variable number in main its 5*/ } int main() { int number; initialize(&number); /* here you are sending address of variable number */ printf("----%d----",number); return 0; }
Write your own rand function which returns random numbers in a given range(input) so that the numbers in the given range is equally likely to appear.
It was asked today in interview but could not crack it, any help.