Vous êtes sur la page 1sur 2

CSEB113 Principles of Programming

CSEB113 Principles of Programming ________________________________________________________________________________ L L A A B B 5 5 : : R

________________________________________________________________________________

LLAABB 55:: RREEVVIISSIIOONN

For each problem below:

  • a) Analyze the problem by identifying input, output, formula, and constraint

  • b) Design an algorithm to solve the problem using pseudocode (so that you could include the pseudocode in your program)

  • c) Prepare several, appropriate number of test data to verify the correctness of your program

  • d) Prepare, compile, link, and execute the program to solve the problem

  • e) Test your program using the prepared test data

  • f) Write proper documentation in the program. Include the following information to form a banner at the beginning of your program:

/****************************************************** * Author’s: your name and student ID *

*

*

*

* Course: the course code only

* Section: your specific section number * Date: of lab session

* Brief description:

*

*

*

of what problem the program tries to solve

* Test data: provide a set of test data

*

*

- input & expected output

*

******************************************************/

QQUUEESSTTIIOONNSS

  • 1. Using several or one printf() statement(s), write a program to print the following logo on the screen.

CSEB113 Principles of Programming

CSEB113 Principles of Programming

  • 2. Write a program to print out the first two letters of your name. Format the program’s output in the following manner:

\----------------------------------------/

\

BBBBB

A

/

\

B

B

A A

/

\

BBBB

A

A

/

\

B

B

AAAAAAA

 

/

\

BBBBB

A

A

/

\----------------------------------------/

CSEB113 Principles of Programming

CSEB113 Principles of Programming ________________________________________________________________________________ 3. Write a program to input your GPA and CGPA. If

________________________________________________________________________________

  • 3. Write a program to input your GPA and CGPA. If your CGPA is higher than 3.9, then produce a beep ten times to celebrate.

  • 4. Write a simple program to determine whether a number entered is an odd or even number. Print “x is odd number” or “x is even number” message on the screen based on the type of the number entered.

  • 5. Write a program that print on the screen a degree classification of a user based on entered gender, and CGPA. Refer to the following table in determining the degree classification. (Please take note that the scenarios presented here are fictitious )

Gender

CGPA

Degree classification

Female

Above 3.75

First-Class Honours

3.00

– 3.74

Upper Second-Class Honours

Male

2.5 – 2.99

Lower Second-Class Honours

2.00

– 2.4

Third-Class Honours

  • 6. Using if…else if, write a basic calculator program that takes two real numbers as input and allows the user to select which operation they would like to perform on the two numbers, either:

    • 1. Addition

    • 2. Subtraction

    • 3. Multiplication

    • 4. Division

Print out the result of the selected operation on the screen. Format the program’s output in the following manner:

-------------------------------------------

Basic Calculator

A: Addition

S: Subtraction M: Multiplication D: Division

-------------------------------------------

Enter two real numbers: x y

Select an operation: z

x operator-based-on-z-value y = t

[End-of-program]

  • 7. Re-write the program for question (6) using switch statement