C is hard -.-"
1
Name:
Anonymous
2013-03-09 0:25
float ran();//Returns a float value in the range [0.0,2.0]
int main(int argc, char *argv[]){
long double return_value=0.0;
unsigned integer x,y=0;
y-=1;
for(x=0;x<y;x++)return_value+=ran();
return_value/=y;
return (int)return_value;
}
What are the chances of this program ending correctly?
2
Name:
Anonymous
2013-03-09 0:30
0%
3
Name:
Anonymous
2013-03-09 0:43
100%.
4
Name:
Anonymous
2013-03-09 2:02
If by correctly, you mean deterministically, then 0%.
5
Name:
Anonymous
2013-03-09 2:18
>unsigned integer x,y=0;
>y-=1;
i bet you were a bad boy/girl and pulled the legs off of bugs -_-
6
Name:
Anonymous
2013-03-09 3:00
t'will always return 0
7
Name:
Anonymous
2013-03-09 3:54
>>5
I'm not a fag so I make MORE READABLE with
TYPEDEF
#typedef int integer
8
Name:
Anonymous
2013-03-09 4:16
>>7
is it better than
#define integer int
?
9
Name:
Anonymous
2013-03-09 7:10
>>7,8
Congratulations, I cringed.
Still better than typedef char *LPCSTR;
10
Name:
Anonymous
2013-03-09 7:19
is the distribution of the return value of ran() flat?
if so, answer should be 50%, no?
11
Name:
Anonymous
2013-03-09 8:05
y = -1;
for(x=0;x<y;x++) return_value += ran(); <- never executes
12
Name:
Anonymous
2013-03-09 9:33
13
Name:
Anonymous
2013-03-10 10:29
This is because you are using a language that discourages higher level thinking and encourages primitive thinking. C is teaching you to be a programming ape. What you need is a language that lets you think about the problem/solution, not one that gets in your way with silly things like syntax.
If it ain't Lisp, it's crap.
14
Name:
Anonymous
2013-03-10 11:01