Ask a New Question

Asked by Tshepo Motsei

Input in a number representing a car type, until the number 0 is
input. There are three types of cars: 1 = luxury, 2 = commercial, 3 =
sedan.
Count how many of each type there are and print out this total with a
message stating what type of car it is.
5 years ago

Answers

Answered by oobleck
int t[1..3]
int n=0
while (n≠0) {
read n
if(n<0) {print error}
else if (n <= 3) {
t[n]++
}
}
for (n=1..3) {
printf "There are %d cars of type %d.",t[n],n
}
5 years ago

Related Questions

Input a list of positive numbers (terminated by 0) into array, find the largest number in the array,... Input a list of positive numbers (terminated by 0) into an array, find the mean (average) of the num... If the input number is 100qhat is the output? input(x): a number output(y): 2 less than 4 times x use the function rule to complete the table i... input(x) a number out put(y): 7 more than 9 times x write an equation to represent the linear fu... Number of inches rule Input Output Arrow divide by 12 Input Output Arrow output Number of feet... Number of years Input Output Arrow Multiply by 12 Input Output Arrow Number of months Numbe... Number of gallons Input Output Arrow Multiply by 8 Input Output Arrow Number of pints Numbe... The number line representing \(d>-4\) has a hollow circle at \(-4\) and an arrow extending to the ri...
Ask a New Question
Archives Contact Us Privacy Policy Terms of Use