Programming (3)

Resources | Revision Questions | Computer Science

Login to see all questions

Click on a question to view the answer

1.

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.

2.

A user enters a password. The program needs to validate the password. The password must be at least 8 characters long AND contain at least one digit. Write a Boolean expression using arithmetic, logical, and Boolean operators to determine if the password is valid. Assume the password is stored in the variable 'passwordLength' (integer) and 'hasDigit' (boolean).

3.

Explain the difference between buffered input and unbuffered input. Give an example of a situation where buffered input would be preferable to unbuffered input.