Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Lab Assignment 5: Basic Types. Arrays. Due date: before your own lab session in the week starting Feb 25 Goal of this assignment: get familiar
Lab Assignment 5: Basic Types. Arrays. Due date: before your own lab session in the week starting Feb 25 Goal of this assignment: get familiar with Basic Types and Arrays, use of library functions practice pseudocode, problem solving methodologies, the translation of pseudocode to C program and test C programs. Use bottom up approach when you edit and test your program. Pay also attention to make your pseudo and C-program correct, Submission Download the new report template and use the new one for your report Submit ONE C file and one WORD file (pseudocode) o Requirement Write pseudocode and translate it to ONE C-program for each the following problems. In your pseudocode and C-program, use only what you have learned in this class so far 1. (Menu) Design a menu for question 2 and 3. So far, you use one program to solve all lab questions. But some of you may feel awkward when you want to demo/test only one lab question. To overcome that, your program should show a menu so that the users of your program can select any question for your program to work on until they choose to quit/terminate your program. Here is an example behavior of your program. At first, it shows a menu 2) Go to question 2 3) Go to question 3 4) Exit. Please type a number from 2 to 4 to select menu item When a user selects 2, your program will go to solve question 2. After question 2 is done, the menu above will be shown to the user again. If the user selects 4, your program will quit. You can certainly reuse/revise your solution for Lab 4 for this problem. 2. (TypeSize Problem) For any primitive type given by a user, print the memory space (i.e size) allocated to this type using sizeof (. function. Example behavior of your program is (red font is user input) This is a calculator of size of a type. 0) int type 1) float type n) Exit Please type a number to select a type: The size of int type is 4bytes (to be continued next page) 0) int type 1) float type n) Exit. Please type a number to select a type: Note that if user type n, your program should show the main menu in 1. You get maximum of 90% of this question if you include only all basic types in L7. The maximum will be 100% if you can address modifiers (long, short, signed, unsigned). As an example, the size of the type unsigned short int is 2 bytes. With modifiers, your menu may be very long. You may use a three-level menu, the first level and second allows the user to choose modifiers while the last level allows the user to choose a basic type. In the first two levels of menu, user should have the option of choosing no modifiers 3. (NumberArray Problem) Ask users to input a series of integers. The input will end with the number 0. Assume users will never input more than 10 integers before input 0. After users input all the numbers, 1) print all the input numbers to the screen in the reverse order they are input by the users, and 2) print the minimal number of the input numbers to the screen, in a user-friendly manner. An example of your program behavior is: (red font for user inputs) Please input a sequence of numbers ended by0: 20 15 The numbers in the reverse order of your input are 15, 20, 3, 1. The minimal number of them is 1 You are expected to use an array to store the input numbers and use the repeat-until- sentinel loop to get the input numbers (and store them into an array) and find the minimal number and generate the display outputs. (Refer to lecture notes L8 on finding minimal number from an array of numbers.) Lab Assignment 5: Basic Types. Arrays. Due date: before your own lab session in the week starting Feb 25 Goal of this assignment: get familiar with Basic Types and Arrays, use of library functions practice pseudocode, problem solving methodologies, the translation of pseudocode to C program and test C programs. Use bottom up approach when you edit and test your program. Pay also attention to make your pseudo and C-program correct, Submission Download the new report template and use the new one for your report Submit ONE C file and one WORD file (pseudocode) o Requirement Write pseudocode and translate it to ONE C-program for each the following problems. In your pseudocode and C-program, use only what you have learned in this class so far 1. (Menu) Design a menu for question 2 and 3. So far, you use one program to solve all lab questions. But some of you may feel awkward when you want to demo/test only one lab question. To overcome that, your program should show a menu so that the users of your program can select any question for your program to work on until they choose to quit/terminate your program. Here is an example behavior of your program. At first, it shows a menu 2) Go to question 2 3) Go to question 3 4) Exit. Please type a number from 2 to 4 to select menu item When a user selects 2, your program will go to solve question 2. After question 2 is done, the menu above will be shown to the user again. If the user selects 4, your program will quit. You can certainly reuse/revise your solution for Lab 4 for this problem. 2. (TypeSize Problem) For any primitive type given by a user, print the memory space (i.e size) allocated to this type using sizeof (. function. Example behavior of your program is (red font is user input) This is a calculator of size of a type. 0) int type 1) float type n) Exit Please type a number to select a type: The size of int type is 4bytes (to be continued next page) 0) int type 1) float type n) Exit. Please type a number to select a type: Note that if user type n, your program should show the main menu in 1. You get maximum of 90% of this question if you include only all basic types in L7. The maximum will be 100% if you can address modifiers (long, short, signed, unsigned). As an example, the size of the type unsigned short int is 2 bytes. With modifiers, your menu may be very long. You may use a three-level menu, the first level and second allows the user to choose modifiers while the last level allows the user to choose a basic type. In the first two levels of menu, user should have the option of choosing no modifiers 3. (NumberArray Problem) Ask users to input a series of integers. The input will end with the number 0. Assume users will never input more than 10 integers before input 0. After users input all the numbers, 1) print all the input numbers to the screen in the reverse order they are input by the users, and 2) print the minimal number of the input numbers to the screen, in a user-friendly manner. An example of your program behavior is: (red font for user inputs) Please input a sequence of numbers ended by0: 20 15 The numbers in the reverse order of your input are 15, 20, 3, 1. The minimal number of them is 1 You are expected to use an array to store the input numbers and use the repeat-until- sentinel loop to get the input numbers (and store them into an array) and find the minimal number and generate the display outputs. (Refer to lecture notes L8 on finding minimal number from an array of numbers.)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started