Programming (3)

Resources | Revision Questions | Computer Science

Login to see all questions

Click on a question to view the answer

1.

A student is writing a program to calculate the area of a rectangle. The program takes the length and width as input from the user. The area is calculated using the formula: Area = Length x Width. Write a flowchart or pseudocode to describe the steps the student should take to create this program.

2.

Consider an array of character values. Write a program in a language of your choice that takes an array of characters and an integer 'index' as input. The program should iterate through the array. If the character at the specified 'index' is a vowel (a, e, i, o, u - case insensitive), replace it with a '*'. If the 'index' is invalid (out of bounds), the program should output an error message and terminate. Assume the array has at least one element.

3.

A program needs to determine if a number entered by the user is within a specific range. The range is defined as being between 10 and 50 (inclusive). Write a flowchart or pseudocode to illustrate how you would implement this using nested conditional statements. Then, provide a short code snippet (in Python) demonstrating the same logic.