(a) Analyse the following code segment. int i=1,x =0; while (i<4) int y=input.nextInt (); if (x>y) x=y; i=i+1; System.out.println(x); (a) What is the output if the following inputs ere entered? Show your working. 8 -5 -1 (b) State the purpose of the code segment above. (c) Rewrite the code segment above by using for loop.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter1: Fundamentals Of C++ Programming
Section1.3: Preliminary Three: Software Development
Problem 3E: (Electrical eng.) You’ve been asked to write a program that outputs the following specifications:...
icon
Related questions
Topic Video
Question
100%
(a)
Analyse the following code segment.
int i=1,x =0;
while (i<4)
int y=input.nextInt ();
if (x>y)
x=y;
i=i+1;
}
System.out.println (x);
(a)
What is the output if the following inputs ere entered? Show your working.
8 -5 -1
(b)
State the purpose of the code segment above.
(c)
Rewrite the code segment above by using for loop.
Transcribed Image Text:(a) Analyse the following code segment. int i=1,x =0; while (i<4) int y=input.nextInt (); if (x>y) x=y; i=i+1; } System.out.println (x); (a) What is the output if the following inputs ere entered? Show your working. 8 -5 -1 (b) State the purpose of the code segment above. (c) Rewrite the code segment above by using for loop.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr