0
Can some one help me with project greatest number
The project says The given code takes 3 numbers as input. Complete the program to output the maximum of the 3 inputs. And this was my answer: nput <- readLines('stdin') x <- as.integer(input[1]) y <- as.integer(input[2]) rangeSum <- function(x, y) { s=0 for (n in x:y) s <- s + n return (s) } print(rangeSum(x, y)) but as I pressed run it say it's wrong so can you help me please
8 ответов
+ 2
what is wrong with this python code to output the Greatest number among three
num1 = 9
num2 = 56
num3 = 42
# uncomment following lines to take three numbers from user
#num1 = float(input("Enter first number: "))
#num2 = float(input("Enter second number: "))
#num3 = float(input("Enter third number: "))
if (num1 >= num2) and (num1 >= num3):
largest = num1
elif (num2 >= num1) and (num2 >= num3):
largest = num2:
else:
largest = num3:
print("The largest number is", largest)
+ 1
num1 = 9
num2 = 56
num3 = 42
# uncomment following lines to take three numbers from user
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
num3 = float(input("Enter third number: "))
if (num1 >= num2) and (num1 >= num3):
largest = num1
elif (num2 >= num1) and (num2 >= num3):
largest = num2:
else:
largest = num3:
print("The largest number is, largest")
0
Mistakes
1. That input not nput
2 using s + n you are resulting the sum of input
0
The code doesn't match the question and task description. Which task do you want to do? Please clarify.
0
#Use this command to learn more about the max() function:
help(max)
0
Input <- readLines('stdin')
x <- as.integer(input[1])
y <- as.integer(input[2])
rangeSum <- function(x, y) {
s=0
for (n in x:y) s <- s + n
return (s)
}
print(rangeSum(x, y))
but as I pressed run it say it's wrong so can you help me please
0
Thx guys B)
- 1
U can use max(x,y )