Question: What does this program do? What would the operating system assume about the programs execution? # define O 1 // That s an oh ,

What does this program do? What would the operating system assume about the programs execution?

# define O 1 // That s an oh , not a zero

int main (){

return O;

}

What does this program do?

// N is a nonnegative integer

double acc = 0;

for ( int i = 1; i <= N; ++ i)

{

double term = ( 1 . 0 / i);

acc += term * term ;

for ( int j = 1; j < i; ++ j)

{

acc *= -1;

}

}

cout << acc << "\ n";

What does this snippet do? Try doing out a few examples with small numbers on paper if youre stuck. (Hint: Think about numbers in binary notation in base 2. How would you express a number as a sum of powers of 2? You may also nd it useful to note that multiplying by 2n is equivalent to multiplying by 2 n times. You should also keep in mind the distributive property of multiplication: a(x + y) = ax + ay.

// bob and dole are integers

int accumulator = 0;

while ( true )

{

if ( dole == 0) break ;

accumulator += (( dole % 2 == 1) ? bob : 0) ;

dole /= 2;

bob *= 2;

}

cout << accumulator << "\ n";

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!