Wednesday, December 08, 2004

C/C++ : Write a function in different ways that will return f(7) = 4 and f(4) = 7.

Solution 1:
int foo(int bar)
{
int ret;
bar==7? ret = 4: ret = 7;
return ret;
}


Solution 2:
int foo(int bar)
{
return 11 - bar;
}

0 Comments:

Post a Comment

<< Home