0% found this document useful (0 votes)
8 views

Humble Test Programing

The document outlines a series of programming tasks and questions related to validation checks, pseudocode algorithms, library routines, subroutines, testing stages, and basic programming concepts in C++. It includes specific requirements for user input, control structures, and the implementation of various algorithms such as generating multiplication tables and simulating login systems. Each question requires a detailed response, including pseudocode and explanations of programming concepts.

Uploaded by

Adil Shahzad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Humble Test Programing

The document outlines a series of programming tasks and questions related to validation checks, pseudocode algorithms, library routines, subroutines, testing stages, and basic programming concepts in C++. It includes specific requirements for user input, control structures, and the implementation of various algorithms such as generating multiplication tables and simulating login systems. Each question requires a detailed response, including pseudocode and explanations of programming concepts.

Uploaded by

Adil Shahzad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Q1.

A program needs to make sure the characters input for a product code meet these rules :

• The product code is six characters in length.

• The first two characters must be “PD”.

• The last four characters must be a number in the range 1000 to 9999 inclusive.

(a) Identify three validation checks and state how each check would make sure the product code
met one of these rules.
(b)
The program design will include a pseudocode algorithm. Assume that the product code is
stored in the variable Product.
Write the pseudocode to make sure that the product code is six characters in length.

Q2. Write the pseudocode statements to perform this task: (0478/21/M/J/24)

• accept the input of a whole number from 1 to 4 inclusive

• use a CASE statement to:

output the number (1 to 4 inclusive) that was entered ○

output the word “ERROR” if a 1 to 4 inclusive number was not entered.

Q3. An algorithm includes a number of complex calculations.( 9618/21/O/N/22) Q1

(a) A programmer is writing a program to implement the algorithm and decides to use library
routines to provide part of the solution.
State three possible benefits of using library routines in the development of the program.
(b)ii. The following pseudocode statement includes array references:
OUTPUT "Student ", Name[Count], " scored ", Mark[Count] State the purpose of the variable
Count and give its data type
Write purpose and dta type.

Q4. A programmer is developing an algorithm to solve a problem. (9618/22/O/N/22 )Q1

Part of the algorithm would be appropriate to implement as a subroutine (a procedure or a function).

(i) State two reasons why the programmer may decide to use a subroutine.
(ii) A procedure header is shown in pseudocode: PROCEDURE MyProc(Count : INTEGER,
Message : STRING) Give the correct term for the identifiers Count and Message and explain
their use.
(b) The algorithm in part (a) is part of a program that will be sold to the public. All the software
errors that were identified during in-house testing have been corrected. Identify and describe
the additional test stage that may be carried out before the program is sold to the public.

Q5. Writing a program that generates a multiplication table for a given number. The
program should:

(c) Ask the user to enter a number (let's call it n).


(d) Print a multiplication table for that number from 1 to 10.
(e) The table should be printed in a matrix format with rows and columns.

Q6. Write a code that print the following pattern. Using for loop

**

***

****

*****

Q7.Write a program that

Asks the user to enter a number n.


Calculates the sum of all integers from 1 to n using a while loop.
Displays the sum.

Q8. Write a C++ program that:

Asks the user to input an integer n.


 Prints all numbers from 1 to n and checks:
 If the number is divisible by 3, print "Divisible by 3".
 If the number is divisible by 5, print "Divisible by 5".
 If the number is divisible by both 3 and 5, print "Divisible by both 3 and 5".
 If the number is not divisible by either, print the number itself.

Q9. Write a C++ program that simulates a basic login system. The program should:

1. Prompt the user to enter a username and password.


2. Continuously ask for the correct username and password until the correct combination
is entered.
3. If the user enters the wrong username or password, display an error message and ask
for the username and password again.
4. Allow the user up to 3 attempts to enter the correct username and password. If the user
exceeds 3 attempts, the program should lock them out and display a "Too many failed
attempts" message.
5. Use a do-while loop to repeat the input prompt until the correct credentials are entered
or the number of attempts exceeds 3.

( The correct username is admin and the correct password is 1234.

Q10.

You are tasked with creating a basic ATM system simulation that performs the following tasks:

1. Prompt the user to enter their PIN code.


2. If the user enters the correct PIN, allow them to access the ATM and choose an option
(check balance, withdraw, deposit).
3. If the user enters the wrong PIN, they are given up to 3 attempts to enter the correct
PIN.
4. If the user enters the wrong PIN three times, the system should lock the user out and
display a message.
5. The program should give the option to:
o Check balance (Display the current balance).
o Withdraw an amount (Ensure the user cannot withdraw more than their current
balance).
o Deposit an amount (Increase the balance by the deposited amount).
6. After performing an action, the user is asked if they want to perform another operation.
If the user enters "yes", they are asked for the next operation. If they enter "no", the
program ends.

Requirements:

 The correct PIN is 1234.


 Initial balance should be set to $100

You might also like