lab03_section_51

pdf

School

University of Windsor *

*We aren’t endorsed by this school

Course

1400

Subject

Computer Science

Date

Jan 9, 2024

Type

pdf

Pages

3

Uploaded by DukeHeat10066

Report
Lab 03- COMP1400 Introduction to Programming and Algorithms Section 51 May 30, 2023 Purpose This lab aims to strengthen your programming skills by practicing the art of breaking down large program- ming questions into small, manageable parts or features. You will need this for the course assignment. In addition, this lab will provide an opportunity to reinforce your understanding and application of input validation, decision-making, and loop structures in the C programming language. 1 Lab Requirements The lab consists of one programming question you must complete before the lab concludes. You have 90 minutes to complete the programming question. The last 30 minutes of the lab is for the TAs to evaluate and discuss your answers. You MUST submit a valid source file to bright space (screenshots or images are not accepted) You are NOT ALLOWED to change your code during the last 30 minutes . Maker sure to continuously show your progress to the lab TA. The program is divided into five features ; when you complete a feature, demonstrate it to the TAs. While working on the questions, you can seek instructor assistance and guidance. You are allowed to refer to the lecture notes and your personal notes and conduct internet searches for assistance. However, it is important to note that directly copying and pasting code from the internet is strictly prohibited. Please ensure you understand and implement the solutions in your own words and code. NOTE: Failing to adhere to the rules and instructions mentioned above may result in the invalidation of your lab submission and could lead to receiving a zero scores . It is crucial to follow the guidelines and complete the lab requirements within the specified time frame while continuously demonstrating your progress to the lab TAs. If you have any questions or need clarification, do not hesitate to seek assistance from the TAs. 2 Lab Questions 1. Write a C program to print a pattern using a given symbol. Ensure your program implementation supports the following features: (a) (15 points) Implement the program logic to print a half pyramid pattern of 3 raw using the provided symbol (*, +, or -). The program prompts the user to enter the symbol choice. Display the pattern based on the chosen symbol. 1
1 Example: 2 Input: 3 Enter the symbol choice (*, +, or -): + 4 Output: 5 Pattern: 6 + 7 + + 8 + + + 9 (b) (15 points) Modify the program to accept the number of rows for the pattern from the user. Ensure to prompt the user to enter the number of rows for the pattern. Update the program logic to print the pattern with the specified number of rows using the chosen symbol. 1 Example: 2 Input: 3 Enter the symbol choice (*, +, or -): * 4 Enter the number of rows: 4 5 Output: 6 Pattern: 7 * 8 * * 9 * * * 10 * * * * 11 (c) (10 points) Enhance the program to validate the user input for the symbol choice. Check if the user enters a valid symbol (*, +, or -). If not, display an error message and prompt the user to enter a valid symbol. Continue validating the input until a valid symbol is entered. 1 Example: 2 Input: 3 Enter the symbol choice (*, +, or -): $ 4 Invalid symbol choice! 5 Enter the symbol choice (*, +, or -): - 6 7 Enter the number of rows: 4 8 Output: 9 Pattern: 10 - 11 - - 12 - - - 13 - - - - 14 (d) (10 points) Extend the program to allow the user to choose the pattern orientation (ascending or descending). Prompt the user to enter the pattern orientation choice (ascending or descending). Update the program logic to print the pattern in the chosen orientation. 1 Example: 2 Input: 3 Enter the symbol choice (*, +, or -): * 4 Enter the number of rows: 5 5 Enter the pattern orientation (press (a) or (d): d 6 Output: 7 Pattern: 8 * * * * * 9 * * * * 10 * * * 11 * * 12 * 13 (e) (10 points) Enhance the program by enforcing input validation on the number of rows by accepting only positive numbers between [2 and 10] and pattern orientation to accept the lower and upper case of a and d only. Continue validating the input until a valid symbol is entered. Page 2
3 Submission Instructions 1. For each question, submit one source file containing your C program implementation. 2. Submit the source code files to bright space; you could either Submit individual files or a single compressed file. 3. Ensure that your submission is completed before the end of the lab. 4. Ask the instructors to review your files/solution before you submit your answer to bright space 4 Evaluation and Feedback As part of the lab, you will be required to showcase your code to the instructors. The instructors will thoroughly test and evaluate your code during the lab session, and a grade will be assigned accordingly. It is expected that the instructors may inquire about the topics covered in the lab and seek explanations regarding your code. Your program will be assessed based on factors such as accuracy, code quality, adherence to guidelines, and efficiency. Table 1: Evaluation Scheme Attendance and Participation (5) Code Quality and Style (5) Code Syntax (5) Code Correctness (60) Lab Discussion (25) Total (100) Page 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help