Question

In: Computer Science

What will be the expected output of the following pseudo code? Write exactly what would display...

What will be the expected output of the following pseudo code? Write exactly what would display when you execute the statements.

Module main()
  Declare Integer a = 5
  Declare Integer b = 2
  Declare Integer c = 3
  Declare Integer result = 0
  Display "The value of result is"
  Display result
  Set result = a + b * c - a
  Display "Changed value is: ", result
End Module

Solutions

Expert Solution

output:

The value of result is

0

Changed value is:6

explanation:

a is initialised with 5

b is initialised with 2

c is initialised with 3

and variable result is initialised with 0

display"The value of result is"

this line enclosed in the double quotes will be printed as it is

therfore initial value of result will be 0 and it will be printed

now the result is set to the expression

a + b * c - a

in which a=5,b=2,c=3

accrding to the bodmas rule

multiplication is done first b*c=2*3=6

since operations done from left to right because +,- are having same precision +is done first

5+6=11

now subraction is done

11-5=6

therefore the new value of result will be updated as 6

and the value after display which is enclosed in double quotes will be printed same and this result is appended after the double quotes seperated by comma

this result will be printed after the double quotes enclosed statement

Changed value is: and the updated value of result i.e 6 is printed

Related Solutions

write exactly what the following code prints. Ensure that you write in the correct order. clearly...
write exactly what the following code prints. Ensure that you write in the correct order. clearly distinguish scratch work from your final answer. Public class Base{ public void m1(Base a){ System.out.println("Base m1"); a.m2(); } public void m2(){ System.out.println("Base m2"); } } Public class Derived1 extends Base{ public void m1(Base b){ System.out.println("Derived1 m1"); } public void m2(){ System.out.println("Derived1 m2"); } } Public class Derived2 extends Base{ public void m2(){ System.out.m2(){ System.out.println("Dertived2 m2"); } } public class UserBaseAndDerived1And2{ public static void main(String[]...
Write the pseudo code for this problem based on what you learned from the video. The...
Write the pseudo code for this problem based on what you learned from the video. The purpose is to design a modular program that asks the user to enter the length and width, and then calculates the area. The formula is as follows: Area = Width x Length
Define a problem utilizing Stacks. Write the design, code and display output. please in c++ oop?
Define a problem utilizing Stacks. Write the design, code and display output. please in c++ oop?
Write the code to return the output in Rstudio. What is the code? Code: x <-...
Write the code to return the output in Rstudio. What is the code? Code: x <- c(28, 69, 5, 88, 19, 20) Output must be: [1] 4 2 1 6 5 3
Write a pseudo code for an O (n7log3n) algorithm. Please write in C++.
Write a pseudo code for an O (n7log3n) algorithm. Please write in C++.
Write VHDL code for the following: Use HEX-to-seven segment display converters to display the inputs and...
Write VHDL code for the following: Use HEX-to-seven segment display converters to display the inputs and results for a 4-bit adder. The inputs are unsigned 4-bit binary numbers. The outcome is a 4-bit binary adder with LED display. First you need to create a symbol for the HEX-to-seven segment display converter. Then implement a 4-bit adder using VHDL. Finally, connect three HEX-to-seven segment display converters to display input X, input Y, and sum S.
(Artificial Intelligence) Write a pseudo code for the following: Regular Hill Climbing with steepest ascent
(Artificial Intelligence) Write a pseudo code for the following: Regular Hill Climbing with steepest ascent
For the following program descriptions, write step by step pseudo code that shows you understand the...
For the following program descriptions, write step by step pseudo code that shows you understand the problem and what it takes to solve it. The first one is done for you as an example. Please answer the questions in the same format as the example problem below so it is the same. Example #1 Problem A customer is purchasing five items. Design a program where you collect the amount of each item, calculate the subTotal of the items, the tax...
what is the expected output of the following segment of code? dq = Deque() dq.push_back('M') dq.push_back('...
what is the expected output of the following segment of code? dq = Deque() dq.push_back('M') dq.push_back(' ') l = ['A', 'L', 'E', 'S', 'T', 'E'] for i in l: → if ord(i) % 3 == 0: → → dq.push_back(i) → elif ord(i) % 5 == 0: → → dq.push_front(i) → → dq.push_back(i) → elif ord(i) % 4 == 0: → → dq.push_back(i) → else: → → dq.peek_front() → → dq.push_front('X') → → dq.push_back('R') dq.push_front(dq.peek_back()) dq.pop_back() print(dq)
1. Write an algorithm to calculate the Matrix multiplication (or write with pseudo code) 2. Write...
1. Write an algorithm to calculate the Matrix multiplication (or write with pseudo code) 2. Write an algorithm to calculate the recursive Matrix multiplication (or write with pseudo code) 3. Find the time complexity of your pseudo code and analyze the differences
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT