hai guy just want to know how to call a function that takes no value and return 1 or 0
what language ? in Java : public boolean func() { //function body } this will return true or false that same to 0 or 1
oh i'm using c++
the same way
let say i,m using that function to give me the tossing result .how can i make it give me the random answers ?
random between true and false ?
ok like rand(1,2) ?
ok I dont remember how to generate a random number in C++ but in Java : Random rand=new Random(); int randNumber=rand.next()%2; I use %2 to get only two numbers : 0 or 1
ok in C ++ its like rand()%2 just did it now and its working
ok man Good Luck
g2g sharp
Ok so your Initial question was how to construct a function returning a specified value of type X. Using ANSI C99 which can pretty much be binded to any other API or ANSI C++, Python, Java as it is a fairly straight forward approach to creating scientific and mathmatical formatting purposes so I will use this as a primer for all communicational purposes. Here is an example of a function of a returning type. /////////////////////////// #include <Global_variable.h> /////////////////////////// float X (void) { if (global_variable_X!=null) { global_output=global_variable; return(global_output); //(1) } else { return(FALSE) //(0) }; }; In the process of calling the function you would have to declare and specify the the "global_variable_X" to be of type float and somewhere in the main program the variable would have to be given a type of float value. For example: float global_variable_X=0.001; I also think to create a random variable you may also choose the modulas operator to get a random value of type float. Example: float X= 1.000; if (X!= 0); { printf("The random value of X is equal to: %f \n", X%); }; I am fairly certain also you should have a copy of "Programming in C" by Stephan kochan or his book on "UNIX" programming at your side at all times for reference material.
hey dude if it's c or c++..jus try placing void for function instead of int then yu can really get a function without any breaking parameters.....for example.... #include<stdio.h> void add(int a,int b); void main() { int a, b; printf("enter two digits"); scand("%d%d",&a,&b); add(a,b); } void add(int a, int b); {int c; c=a+b; printf("addition is %d",c); }
Join our real-time social learning platform and learn together with your friends!