Question: 6. What is wrong here? Happy Hacker likes to write code but he doesnt like to study the theory. He wrote the following chunks of

6. What is wrong here? Happy Hacker likes to write code but he doesnt like to study the theory. He wrote the following chunks of code and was puzzled why they didnt work. Can you help Happy? (a) This loop should generate a hundred thousand random numbers between 0 and 99 and count the 99s. But it doesnt stop, why? short n, targets, k; for(targets = k = 0; k<100000; ++k ) { n = rand() % 100; if (n == 99) ++targets; } (b) Happys loop should print a table of values of sin(x), where x goes from 0 to 1 in steps of 0.01. But it doesnt stop, why? double x = 0; while (x != 1) { printf( "%9.6f ", sin(x) ); x += .01; } (c) Happy used a float variable, star, to store the distance from here to the edge of our galaxy (74,000 light years away), in miles. One light year is 5.879e+12 miles. He used another float variable, mall, to store the distance from here to the nearest shopping mall, in miles. He cant understand why star + mall is the same value as star. Help him; explain why.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!