Worksheet 12. 1/14. 1: for testing basic understanding 1
Download 285.78 Kb. Pdf ko'rish
|
Worksheet 12 14.1 (1)
© Cambridge University Press 2019 Worksheet 12.1/14.1: for testing basic understanding 1 Write a program that will take as input the length and width of a rectangular garden and will calculate and output the surface area. 2 Write a program that will take as input a temperature in degrees Fahrenheit and will convert and output the temperature in degrees Celsius. (Hint: DegreesC = (DegreesF – 32) * 5/9) 3 Write a program that will take as input the air temperature in degrees Celsius and will output a message to say whether it is freezing (below 1 degree) or not. 4 Amend your program from Question 3 to say whether the water in a container is frozen, liquid or boiling. 5 Write a program that will take as input an integer between 1 and 12 (inclusive). The program should output the name of the month corresponding to the number input. For example, an input of 2 will output ‘February’. Hint: use a CASE statement. 6 Write a program that will take as input a positive integer and will output integers counting from 1 to the number input. For example, an input of 5 will output: 1 2 3 4 5 7 Amend your program from Question 6 to count down from the number input to 1. For example, an input of 5 will output: 5 4 3 2 1 8 Amend your program from Question 6 to take as input a second integer to be used as the counting interval. For example, the input of 20, 4 will output: 1 5 9 13 17 9 Write a program that will take as input ten numbers and output the largest number. 10 Amend your program from Question 9 to output the smallest number. 11 Write a program that asks the user for an integer between 1 and 5 (inclusive). The program should check that the input is within the range and if not, prompt the user for a valid integer until the input is within the range. 12 Write a program that will take as input two positive integers. The program should output integers counting from the first integer to the second integer. For example, the input 3, 7 will output: 3 4 5 6 7 13 Write a program that will take as input a character and output the ASCII code for that character. 14 Write a program that will take as input an ASCII code and output the character with that ASCII code. 15 Write a program that will take as input a string and output the number of characters in the input string. 16 Write a program that will take as input a string and output the two leftmost characters. 17 Amend your program from Question 16 to output the two rightmost characters. 18 Write a program that will take as input a string and will calculate the middle position and output the middle character. If the string length is an even number the two middle characters are to be output. 19 Write a program that will take two input strings: a first name and surname. The program should produce the full name by concatenating the first name and surname with a space in between them then to output the full name. 20 Amend your program from Question 19 to produce a name string made up from the first letter of the first name, a space and the surname. 21 Write a program that will take as input a number with a decimal point and output the nearest whole number. 22 Write a program that generates and outputs five random numbers. Run the program several times to ensure they are not the same numbers each time. Download 285.78 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling