Question

In: Computer Science

n following code if variable n=0, a=5 and b=10 then what will be the value of...

n following code if variable n=0, a=5 and b=10 then what will be the value of variable ‘n’ after while loop executed. Show your working as well.

while(n<=(a^b)) { n++; } printf("%d",n)

Solutions

Expert Solution


___________________________________________________________________

while(n<=9765625){
    n++;
}


Iteration No Initial value of n Final value of n
1 0 1
2 1 2
3 2 3
4 3 4
... ... ...
9765624 9765623 9765624
9765625 9765624 9765625
9765626 9765625 9765626

printf("%d",n)

___________________________________________________________________


Note: If you have queries or confusion regarding this question, please leave a comment. I would be happy to help you. If you find it to be useful, please upvote.


Related Solutions

What is the value of n after this code runs? 1 Point int n = 0;...
What is the value of n after this code runs? 1 Point int n = 0; int j = 7; if ((j!=0) && (n < 25)) { n = 1; if (j > 4) { n = 2; } else { n = 3; } } else { n = 4; if (j%2 >= 2) { n = 5; } else { n = 6; } }
What is the last value of variable x? y = 0 x = 0 while y<=10:...
What is the last value of variable x? y = 0 x = 0 while y<=10: if y%2==0: x = x + 2 y += 1
1) At the end of the following algorithm segment, what value is in variable n? n:=...
1) At the end of the following algorithm segment, what value is in variable n? n:= 31 WHILE ( n is prime) n:= n -2 END WHILE 2) Prove that there is no greatest negative real number using contradiction or contraposition.
What is the output of the following code: x = 0 a = 1 b =...
What is the output of the following code: x = 0 a = 1 b = -3 if a > 0:    if b < 0:       x = x + 5    elif a > 5:       x = x + 4    else:       x = x + 3 else:     x = x + 2 print(x) 4 2 5 3 Consider the following code segment:    sum = 0.0    while True:       number = input(“Enter a...
Stock Expected Dividend Expected Capital Gain A $0 $10 B 5 5 C 10 0 a....
Stock Expected Dividend Expected Capital Gain A $0 $10 B 5 5 C 10 0 a. If each stock is priced at $100, what are the expected net percentage returns on each stock to (i) a pension fund that does not pay taxes, (ii) a corporation paying tax at 45% (the effective tax rate on dividends received by corporations is 10.5%), and (iii) an individual with an effective tax rate of 10% on dividends and 5% on capital gains? (Do...
Review the following code: Sub RunLoop() For n = 1 to 100 ActiveSheet.Range("A" & n).Value =...
Review the following code: Sub RunLoop() For n = 1 to 100 ActiveSheet.Range("A" & n).Value = n End Sub
Consider the following vectors: →a = 5 −1 3 3 →b = 5 0 1 0...
Consider the following vectors: →a = 5 −1 3 3 →b = 5 0 1 0 →c = −10 3 −3 −7 For each of the following vectors, determine whether it is in span{→a, →b, →c}. If so, express it as a linear combination using a, b, and c as the names of the vectors above. →v1 = 5 −3 2 7 < Select an answer > →v2 = 2 7 6 −7 < Select an answer > →v3 =...
What is the final value of variable x? x = 0 msg = "hello there!" for...
What is the final value of variable x? x = 0 msg = "hello there!" for character in msg: if character=="e": x += 1
1. Translate the following code into MIPS code. B[i + 10] = B[i -2] + 40;...
1. Translate the following code into MIPS code. B[i + 10] = B[i -2] + 40; i = i + 10; B[3] = B[i - 1]; a) Assume B is an array of integers (each integer takes 4 bytes). B's address is stored at register $10. Also assume that the compiler associates the variable i to the register $11. b) Assume B is an array of characters (each character takes one byte). B's address is stored at register $10. Also...
What is the payback period for the following investment given that (a) i=0% and (b) i=10%?...
What is the payback period for the following investment given that (a) i=0% and (b) i=10%? Site Initial Cost Annual Cost Annual Income Maximum Life Salvage Value X 1,000,000 100,000 300,000 10 yrs 500,000 By hand please.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT