Question

How many times does the following loop execute and why? for (unsigned m = 5; --m...

How many times does the following loop execute and why?

for (unsigned m = 5; --m >= 0; )

printf(“hello\n”);

Homework Answers

Answer #1

it will run infinite time. beacuse the condition -- m>= 0 is always true . it is always true beacuse m is unsigned and it always return +ve value. .

4 byte unsigned value ranges from 0 to 4294967295

that means

unsigned 2 =2

unsigned 1 =1

unsigned 0 =0

unsigned -1 = 4294967295

unsigned -2 =4294967294

unsigned -3=4294967293

proof: -

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
IN JAVA PLEASE How many times does the while loop execute for the given input values...
IN JAVA PLEASE How many times does the while loop execute for the given input values of -1 4 0 9 userNum=3;while (userNum>0){ //Do something //Get usernum firm input }
Write a C program that prompts the user to input as many unsigned(n) as the user...
Write a C program that prompts the user to input as many unsigned(n) as the user wants to type, terminated by non negative number You may assume without checking that when the user is supposed to type an unsigned, he nevertypes a double You may assume without checking that when the user is supposed to type an unsigned, he nevertypes a negative number. For each number the user types, output whether that number is prime or not. You won't need...
java beginner level NO ARRAYS in program Flip a coin (Assignment) How many times in a...
java beginner level NO ARRAYS in program Flip a coin (Assignment) How many times in a row can you flip a coin and gets heads? Use the random number generator to simulate the flipping of the coin. 0 means heads, 1 means tails. Start a loop, flip it, if heads, count it and keep flipping. If tails, stop the loop. Display the number of times in a row that heads came up. Once this is working, wrap a while loop...
Estimate: On a typical day, how many times in the world is the English word "Hello"...
Estimate: On a typical day, how many times in the world is the English word "Hello" spoken?
I'm trying to figure out why my program has an infinite loop. I'm pretty sure it...
I'm trying to figure out why my program has an infinite loop. I'm pretty sure it has something to do with the catch(bad_alloc) function or maybe the while (true) loop above it but I'm not sure. Can you help me figure out why i have an infinite loop and help me fix it? Thanks ---------------------------------- main.cc ---------------------------- #include #include #include #include "numbers.h" using namespace std; int main() { Numbers N1, N2;       for(size_t i = 2; i < 16;...
Loop unroll the following MIPS code loop 4 times. Write the resulting code including any re-ordering...
Loop unroll the following MIPS code loop 4 times. Write the resulting code including any re-ordering necessary for maximum performance. loop: sw $zero, 0($s0) addi $s0, $s0, -4 bne $s0, $zero, loop
How long does the following piece of assembly language take to execute (assuming a 12MHz clock...
How long does the following piece of assembly language take to execute (assuming a 12MHz clock frequency)?: MOV A,#55h MUL AB JMP NEXT NEXT: MOV P2,A MOV P3, B
1.Write a for loop that displays the run number and your full name 5 times on...
1.Write a for loop that displays the run number and your full name 5 times on the command window. Your output should look similar to following: using matlab
A streak isolation with 4 total section on a TSA plate how many times did you...
A streak isolation with 4 total section on a TSA plate how many times did you sterilize your inoculating loop
If |A| = n and |B| = m, how many functions are there mapping A to...
If |A| = n and |B| = m, how many functions are there mapping A to B? if n > m, How many are one to one? if n = m, How many are one to one (give your answer in terms of n)? if m > n, How many are one to one?
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT