#Write a program that uses a loop to find the minimum of a vector x, with using any predefined functions like min(...) or sort(…..). #vector x x <- c(50,55,40,3,6,70,69,48,1004,564) #initial first value of x as smallest x.min<- 0 #loop to parse through x for (i in length(x)){ if (x[i] < x.min) { x.min <- x[i]} } else{ } i <- i + 1 print(x.min)

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section7.6: The Standard Template Library (stl)
Problem 8E
icon
Related questions
Question
100%

Question 6 sam

Why is my code not printing the lowest number in the vector?

148 #Write a program that uses a loop to find the minimum of a vector x, with
using any predefined functions like min(…..) or sort(…..).
149
150 #vector x
151 x <- c(50,55,40,3,6,70,69,48,1004,564)
152 #initial first value of x as smallest
153 x.min<- 0
154 #loop to parse through x
155
156
4
157.
158.
for (i in length(x)){
if (x[i] < x.min) {
x.min <- x[i]}
else{
159
160
161
162 }
163
164 print(x.min)
i <- i + 1
}
Transcribed Image Text:148 #Write a program that uses a loop to find the minimum of a vector x, with using any predefined functions like min(…..) or sort(…..). 149 150 #vector x 151 x <- c(50,55,40,3,6,70,69,48,1004,564) 152 #initial first value of x as smallest 153 x.min<- 0 154 #loop to parse through x 155 156 4 157. 158. for (i in length(x)){ if (x[i] < x.min) { x.min <- x[i]} else{ 159 160 161 162 } 163 164 print(x.min) i <- i + 1 }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Array
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