EEET2246 – Engineering Computing 1 – Week 5 and 6 Laboratory Tasks

Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due

EEET2246 – Engineering Computing 1 – Week 5 and 6 Laboratory Tasks

Due: Friday - Week 7, 11:59pm via Canvas / Total Marks 10%.

Overview:

Laboratory Exercise 2 consists of two sets of Laboratory Tasks (defined in this document) and one Laboratory Code Submission assignment (Laboratory Code Submission 2). The Laboratory Tasks are designed to help you build your code solution for the corresponding test. Part A is designed to be completed in week 5, whereas, Part B should be completed in week 6. Your combined report for Part A (worth 5%) and Part B (worth 5%), as well as your Laboratory Code Submission 2 submission (worth 10%) are due in week 7 via Canvas. The total combined value for Laboratory Exercise 2 is 20% of your final mark for EEET2246. Remember that the Lab code submission is a separate assessment and should only be a single *.cpp file.

All assessment items for Laboratory Exercise 2 are due by Friday, Week 7 at 11:59pm.

IMPORTANT: If you are taking an online laboratory, please use the Collaborate Ultra Laboratory sessions as Q & A sessions to work through the tasks. In all cases, your laboratory tutor will not mark any work during these sessions and will be available online during this time to answer questions and provide assistance.

Assessment:

There are two types of tasks – explanation- and code-based. Explanation questions require you to provide a diagram, pseudocode, written descriptive answer and/or screen captures based on the question in your report. These types of questions will have a heading of Explanation based.

Code-based means you will need to submit a working standalone *.cpp file. This type of question can be identified by the heading Code CPP file Required. The submitted *.cpp files must be fully functional and compile without modification to achieve full marks. Each question that is marked as “Code CPP file Required” requires a separate *.cpp file to be submitted. The naming convention is as follows: ‘s1234567_PartA_TaskAx.cpp’, where s1234567 is your student number and PartA_TaskAx corresponds to the actual question you are answering. You may also need to supply some screen captures of your program under different situations and a brief description in your lab report to assist your tutor running your code or describing its operation, etc. Without this you may not get a mark for a submitted piece of code unless it is extremely obvious how it is meant to work. However, please do not put screen captures in your report that have unnecessary information in them that does not relate directly to the question.

Note: Some tasks will not attract any marks at all. These tasks are either introductory or bridging tasks to assist in your understanding of the topic. The report only needs to provide the required diagrams and text to inform the assessor (your lab tutor) what the required inputs are and the expected output of your code. Text explanations should be kept to a minimum and it is suggested to use dot points where possible. The report should use the same question number referencing as this document so that it is clear which answers are for what task/questions.

IMPORTANT: Lab Report Page Limit will apply to this assessment item. Your combined Lab Report for week 5 and 6 Tasks should be no longer than 10 pages long (including all diagrams and images). The shorter and more succinct the report the better. That is, if you can answer all questions in 3 to 5 pages, then please do so. Any answers that go over the page limit will be ignored by the tutor, hence you will lose marks (unless you have prior approval from your lab tutor).

Note: All tasks are marked on a scale, however, if code is not submitted for a given task (when required) or if it does not compile, you will not score marks for that item.

Regardless of the study mode, please use the Collaborate Ultra Lab session or the face-to-face lab sessions as a Q&A to work through the tasks. Your lab tutor will not mark any work during any of the online or face-to-face sessions and will only be available during the laboratory class session time to answer questions and provide assistance.

Submission Process:

You will be required to submit a report with specific standalone *.cpp files to address the tasks outlined in this document. Your Lab Report document should contain the content relating to both Part A and Part B tasks. Please do not submit all tasks in one *.cpp file unless you have discussed this with your lab demonstrator/tutor.

THE FIRST PAGE OF THE REPORT MUST SPECIFY: Your full name, Student number, number of *.cpp files submitted, enrolled Laboratory session time slot and tutor name. The report along with *.cpp files must be uploaded via Canvas before the deadline to avoid any late penalties.

Late penalties: Assessments that are received late and without prior extension approval or special consideration will be penalised by a deduction of 10% of the total score possible per calendar day late for that assessment.

Suggested Lab Report format:

Lab Report should be a PDF or word document.
  • First page must contain your full name, Student number, number of *.cpp files submitted, enrolled Laboratory session time slot and tutor name.
  • Only 1 Lab Report document is required for each lab exercise. Therefore, both Part A and Part B tasks should be presented within the same Lab Report document.
  • The document should use section headings that match the dot points within the lab guide, such as:
    • Part A, Task 3:
    • Part A, Task 4:
    • Part B, Task 2:
You can list tasks that don’t attract marks for completeness, however, remember that there is a page limit to the overall report.
  • For questions that require a code CPP file , you must submit a standalone *.cpp file that has a filename that correlates to the task. For example: PartA_Task6.cpp
  • It is recommended that you also have an appropriately titled section heading (e.g. Part A, Task 6 code:) in the report detailing how to run the file with example input arguments, etc. pointing out what happens under normal situation and/or a corner case.
  • Remember to make good use of screenshots and images as part of your answer to demonstrate the codes behaviour, etc.
  • Short dot points answers are preferred.
  • Remember that your tutor is looking that you have understood the task and the concept it relates too.

Part A – Week 5 (5%)

Aim:
The aim of these laboratory tasks is to continue developing your C++ skills within the Microsoft Visual Studio 2022 Integrated Development Environment (IDE). When combined with the Week 6 Laboratory Tasks, you will have effectively developed the necessary code for a significant portion of the Laboratory Code Submission 2 which is due at the end of Week 7. You are strongly recommended to download and familiarize yourself with the Laboratory Code Submission 2 proforma *.cpp file which is available on Canvas and start writing your solution after completing these tasks.

An essential requirement for Engineers is the ability to write software that will interface with a wide variety of hardware systems. In the EEET2246 laboratories we will be using the OUSB Board to demonstrate how software can interact with hardware and the influence that this has on the software we will be developing. For students that do not have access to a physical OUSB Board, the OUSB Board Simulator can be used. Note that the OUSB Board interface software (ousb.exe) and the Simulator (ousbsim.exe) only work under a Microsoft Windows based PC environment and must be used with a directory pathing that is on a local hard drive with no white space characters in the path name (i.e., avoid using networked drives and default user profile locations). The details of the OUSB Board interface software and the OUSB Board Simulator can be found on the course ‘Canvas’ website under the OUSB Board Resources page.

IMPORTANT:
Interfacing your programs with hardware will present a new series of challenges. To simplify the text within this document and the Laboratory Code Submission 2 proforma, all references to the OUSB Board will assume you have access to a Physical OUSB Board using the standard ousb.exe interface software (unless stated otherwise). If you are using the OUSB Board Simulator, you can either replace the ousb command with ousbsim, or you can choose to rename the simulator to from ousbsim.exe to ousb.exe and use it instead. In the case of the Real ousb.exe program, the ousb.exe interface software takes care of the USB communication protocol between the PC and the Physical Board. Whereas, in the case of the OUSB Simulator, the ousbsim.exe program stores the state of a Virtual OUSB board’s registers in simple text files in the same directory that the ousbsim.exe (or the renamed) file it is located in.

NOTE: All Laboratory Exercise 2 Tasks and Code Submission 2 can be completed with the ousbsim.exe simulator alone. Just remember to rename the simulator to ousb.exe so that you only use the ousb command in the Lab Code Submission.

If you are using only the Physical OUSB Board it is also suggested that you obtain a copy of the ousbsim.exe file to explore how it differs from the real ousb.exe file. Also, all students should read the OUSB Board reference manual which is available on the EEET2246 Canvas site as well as on the www.pjradcliffe.wordpress.com website.

This laboratory will require you to perform the following tasks with the OUSB Board:

  • Use the provided ousb.exe or ousbsim.exe file to explore the various command-line options.
  • With the aid of the reference manual determine the parameters required to write an integer value to the OUSB Board Light Emitting Diodes (LEDs) on PORTB. 
  • Use the provided template code to create a ‘communication pipe’ between your application and the ousb.exe or/and ousbsim.exe executable.
  • Convert the value of the OUSB Board switch state to an integer that can be used for further calculations.
Furthermore, you should become more familiar with the Visual Studio IDE and how to use its debugging features such as breakpoints and ‘watch’ windows.

This week you are encouraged to build up your code solutions sequentially (where appropriate) as you move through each task, however you should keep a copy of each solution as a standalone piece of code by using block comment (/* */) to save the code for future reference.

Remember to use the lecture notes as a reference as well as the prescribed textbook and the OUSB Board reference manual.

Tasks

1. To communicate with a OUSB Board, an intermediate program is required (ousb.exe). This file can be downloaded from the EEET2246 Canvas shell website by navigating to the Modules page and then selecting ‘OUSB Board Resources’ page. Once on the “OUSB Board Resources” page, download the ousb.exe file by clicking on ‘ousb.exe’ link. For your application to access the ousb.exe file, it must be placed in the same folder (directory) as your *.cpp file. However, initially, we will explore the various command-line options of the ousb.exe application by sending it commands via the console command window. To do this, create a new Visual Studio Project and place the ousb.exe file in the same folder as the projects *.cpp file. Open a command prompt (using the techniques developed in laboratory exercise 1 tasks) and navigate to the folder containing your Visual Studio project with the ousb.exe file in it. Run the executable by typing ‘ousb’ and then press enter at the command line console. You should be displayed with a screen similar to Figure 1.


Figure 1 – ousb.exe Command Line Options which is used to communicate to a Physical OUSB Board

If you are using the OUSB Simulator, the exact same command line arguments can be used, however, you will either need to rename the ousbsim.exe file to ousb.exe or use the ousbsim as your command. Figure 2 shows the help screen for the OUSB Simulator. Notice that it has a different version number and slightly different help screen.


Figure 2 – ousbsim.exe Simulator Command Line Options which is used to communicate to a Virtual OUSB Board

Regardless of if you are using a Physical OUSB Board or using the OUSB Simulator, it is helpful to understand what the simulator is trying to emulate. Below is a picture of a Physical OUSB Board showing the DIP switches connected to PINC and the 8 LEDs connected to PORTB.

Figure 3 - OUSB Board showing the DIP switches connected to PINC and the 8 LEDs connected to PORTB.

The LEDs on the OUSB Board are connected to the individual bits of PORTB, from bit 0 through to bit 7. Hence PORTB can represent the values 0 to 255 in binary (0b00000000 – 0b11111111). Similarly, each switch is connected to the input of PORTC. However, as these bits are setup as inputs, you would need to read the value of the DIP switches using the PINC register (pronounced as “Port In C”). Additionally, the wiring of the DIP switches inverts the logic on the port. This results in the settings shown in Figure 2 having a value of 254 (0b11111110) as bit 0 is set to ON (which is grounded). 

Given the description of the parameters in Figure 1 through to Figure 3, determine the command line arguments that would be required to turn on every second LED (Most Significant to Least Significant) on the  using either the ousb.exe or ousbsim.exe application. In the case of the simulator, the value you will want the simulator to write to the portb.txt file will be the decimal equivalent of 0b10101010 or 0b01010101.

Hint: What value is required to turn a LED on and how can you determine the value in binary? You can also use the OUSB Board reference manual to determine the name of the register that is connected to the 8 LEDs on the board.

2. Another requirement for the Laboratory Code Submission 2 is to read input from the DIP switches on the OUSB Board. Based on the discussion above and the OUSB reference manual, what would the command be to read the current value of the DIP switches? What is the position of the switches to obtain a reading of 63 decimal? If using the OUSB Simulator, confirm your answer by setting the corresponding virtual switch value (via the pinc.txt file) and obtaining the results from the ousbsim.exe application, then draw a simple diagram of the DIP switch shown in Figure 3 and indicate which switches would be set to high and low positions. Remember that they are electrically inverted.

Explanation based

3. From the results obtained in Questions 1 and 2, the output contained significantly more information than required if you did not use the output format flag. What command line switch would be required to display the output from the OUSB Board as only a decimal value? Repeat Questions 1 and 2 with the modified command which incorporates the optional flag. Place a screenshot and a small discussion in your report demonstrating the difference in command lines for Questions 1 – 3. [2 marks]

Explanation based

4. The tasks up until now have utilised the command line to run the ousb.exe (or ousbsim.exe) executable. Whilst demonstrating how the application/s operate and the parameters required, this technique needs to be extended for the Laboratory Code Submission 2. One method that can be utilised to communicate with an external application from your program is by utilising a construct known as a ‘pipe’.

You can think of a ‘pipe’ as a method of transferring data from one application to another. Utilising a ‘pipe’ allows commands to be sent to the ousb.exe application and for the data produced by the ousb.exe application to be returned back through the pipe (to the original program that opened the pipe).

As a starting point, it is suggested that you download the ‘OUSB_getting_started_code.cpp’ file from the Canvas shell (under ‘Week 5 and 6 Laboratory Tasks’ page). This code example contains the all the basic code required to communicate to the ousb.exe or ousbsim.exe executable via a C/C++ pipe.

The OUSB_getting_started_code.cpp is fully commented, and it is highly recommended that you work through each line it in detail using the lecture (and supplementary) notes as a reference / resource. Note that the essential communication code will be provided in the Laboratory Code Submission 2 proforma, so there is no need to memorise the exact syntax of the pipe code; rather you just need to know how to use it.

For this task, identify the code that is responsible for writing to ‘PORTB’ via the ousb.exe or ousbsim.exe executable. Write a program by copying the relevant OUSB commands from Question 1 into your program and use a program control statement to automatically increment the value of ‘PORTB’ from 0 to 100 with a step size of 1. Note that you should open and close the pipe (_popen() and _pclose()) every time you attempt to read / update the values of the LEDS.

Hint: Consider using the _itoa_s() function. Take a screenshot of the console window (and/or photo of the board) demonstrating that the OUSB board is being updated.

Hint: You might also find the ‘OUSB_Multi_read_write_example.cpp’ file useful too, however you should write the pipe code within a for loop instead of coping it over and over again to get full marks to overcome the issues presented in the ‘OUSB_Multi_read_write_example.cpp’ file. [2 marks]

Explanation based

5. Now that you have been able to write data to the PORTB LEDs on the OUSB Board, the next step is to obtain the current value of the 8 DIP switches on PINC. From the result of Task 2, set the switches to decimal 63 (either physically or via the pinc.txt file). Refer back to the ‘OUSB_getting_started_code.cpp’ file and determine the portion of the code that reads data form the board. Copy the relevant code into your application and extend it to develop a small application that outputs the data returned from the OUSB Board to the console in decimal mode. Only output the value that has been read from the switches and display it to the console screen without any additional text. Hint: You will need to modify the command variable text with the name of the register that is connected to the DIP switches on the OUSB Board. Note: Use the OUSB Board Reference manual to determine the correct command. Provide a screenshot of the actual ‘switch’ value and the corresponding output from your solution. [2 marks]

Code CPP file Required and Explanation based

6. In the ‘OUSB_getting_started_code.cpp’ file, the data obtained from the OUSB Board is returned as a character array in the variable ‘line’. From your previous work in task 5, what should be done to convert the characters representing the value of 'pinc' back into an integer value? Is there a library function that can help convert the string that contains ASCII numerical characters to a valid data type to that holds numbers?

Extend your program to read the value of 'pinc', convert the characters into an integer and then add 12 to it before displaying the final value on 'portb' and on the console. Explain in your report what the maximum value of pinc can be before you have issues writing the final value to portb. (i.e. relate your discussion back to the maximum value that can be displayed on portb).

Hint: Consider using the _itoa_s() and atoi() functions together with some string modification functions such as strcpy_s() and strcat_s(). What parameters do the functions take? You might consider search or reading about each function on the Microsoft Developer Network: msdn.microsoft.com. Submit you code for this question. [4 mark]

Once you have finished these tasks you are free to start your week 6 lab tasks. You can also start write your solution to the Laboratory Code Submission 2 assessment item. Make sure that you download and read the Laboratory Code Submission 2 proforma *.cpp file which is available on Canvas. 

Part B – Week 6 (5%)

Aim:
The aim of these laboratory tasks is to continue developing your C++ skills within the Microsoft Visual Studio Integrated Development Environment (IDE). When combined with the Week 5 Laboratory Tasks, you will have effectively developed the necessary code for a significant portion of your Laboratory Code Submission 2. You are strongly recommended to download and familiarize yourself with the Laboratory Code Submission 2 proforma *.cpp file which is available on Canvas and start writing your full solution after completing these tasks.

To date, many of the programs that you have written are based around the use of program control statements and converting user input (in the form of command line arguments) into numerical form. However, as you begin to write more complex programs additional functionality will be required. Whilst most processes can be developed based on the material we have covered, one of the key benefits of using a programming language such as C++ is the ability to incorporate code that has been written by others. In C++, we can do this by utilising a concept known as functions.

A function can either be provided as part of the programming language (inbuilt function) or you can create a user-defined function (developed by the programmer) to perform a specific task. The aim of a function is to create a reusable piece of code that can be applied to many situations. For example, to convert an character array (such as argv[][]) to a floating point number we have already used the atof() function. In C++, there are a wide variety of functions available for use which are consistent between different operating systems (Microsoft Windows, MacOS and Linux). A subset of the same functions also exists for embedded hardware environments such as the OUSB Board.

A function (definition) consists of three core components which are the function name, function parameters and the function return type. If we take a C++ function atof() that we have been using throughout this course, the full function definition is written as: ( http://www.cplusplus.com/reference/ ) double atof (const char * str);

In this example, the function name is atof(), the function parameters are a constant character pointer (const char *) and the function return type is a double. We will discuss the details of a character pointer later in the lecture series, but if you closely examine the main() function in all of your C++ programs you will notice that argc is of type char * and hence the parameters match. Note that you typically cannot directly use a function if the parameter data types do not match. More details will be provided in the lecture material “Introduction to Functions”.
This laboratory will require you to perform the following tasks with a variety of functions:
  • Determine the absolute value of a numerical data type.
  • Utilise a function to determine if a command line argument contains only numerical data.
  • Create extended functionality to determine if the command line argument contains other valid characters for numerical data types.
  • Join two null-terminated strings together with the aid of a string function and write the result out to the OUSB Board (either simulated or a physical OUSB Board).
  • Compare two null-terminated strings using a string function.
  • Read data from the DIP switches on the simulated OUSB board that are connected to PORTC (PINC).
Furthermore, you should become more familiar with the IDE and how to use its debugging features such as breakpoints and ‘watch’ windows.
This week you are encouraged to build up your code solutions sequentially (where appropriate) as you move through each task, however you should keep a copy of each solution as a standalone piece of code by using block comment (/* */) to save the solutions for future reference.
Remember to use the lecture notes as a reference as well as the prescribed textbook.
Tasks
1. When working with simulated hardware such as the OUSB Board, it is important that the correct data types are transmitted for further processing. Any data sent should be in the correct range otherwise undefined behaviour may occur causing at best an error message, or in a worst case a system crash. As an example, consider the OUSB Board LEDs which are PORTB. Using the ousb.exe or ousbsim.exe program, determine the effect of writing a negative number to the OUSB LEDs. What is the response and is it what you expected?
Explanation based
2. In the case of the OUSB Board (and simulator) sending a negative number does not cause a catastrophic failure. However, any data written to the PORTB LEDs should be an absolute value (positive) and between 0 and 255 for it to be accepted. To convert a negative number to positive an absolute function is required.

Using the C++ reference website ( http://www.cplusplus.com/reference/ ) determine how the abs() function can be used. What are the function parameters and the return type? Write a small program that defines a negative integer (between -1 and -255), converts it to a positive value and then displays it on the console window. Place a table in your report indicating the specific values you applied to your code as well as an example of the output. [2 marks]

3. One of the issues that we have been facing throughout the course is the ability to detect valid user input.
Any user input needs to be carefully examined to ensure that it meets the necessary requirements before any further processing is performed or unexpected behaviour could result. To determine if an input argument is valid we have been iterating through the input arguments checking to see whether every character is between '0' and '9'. As you would know by now, this can be achieved by using a compounded logical expression or the isdigit() function in and 'if' statement that is inside a 'for' loop. The full function prototype for the isdigit() function is given as:
int isdigit ( int c );
The isdigit() function takes an integer 'c' as an input and then returns a non-zero value if the value of 'c' is a valid ASCII digit. Note that even though the input parameter 'c' is an integer, in this case the complier will convert an input character to an integer for you via an implicit casting operation.

Via the command line arguments enter the value of 168. Write a small program to determine if the input argument is truly numerical by stepping through the argument via a 'for' loop using the two different methods: a compounded logical expression and the isdigit() function. At the first invalid digit your program should display an error message and exit. Change the command line argument to 45a21 to check your result.

Note: You may have already used one of the discussed methods in Lab exercise 1, however here you should explicitly write the code using the two different methods as separate code blocks.
Explanation based
4. The code written in the previous question was only capable of determining if a numerical digit was entered.
For example, what would be the output if you entered 168.03? Extend your program to allow other valid characters such as a decimal point, +/- signs, and scientific notation.
Rewrite your solution/s to include decimal point, +/- signs, and scientific notation.
Note: To get full marks for this task, you should discuss how you will check the placement of the exponent character, the sign character and the decimal ‘.’ Character. List the various inputs and corresponding outputs in your report and with a screenshot of the terminal window demonstrate the output for one of your test values. If your code explanation is only suitable to handle numbers like 45a21 or 1.2.3 then you will only get half marks for this question. How would you handle: +100.5e-2 [2 marks]
Explanation based
5. When communicating with the OUSB Board it is often essential to send a command followed by a numerical value. For example, to display the decimal value of 42 on the LEDs, the following command would be required:
ousb –r io PORTB 42
In the case where you wanted to update the OUSB LEDs value, then a similar command would be required, with the exception of the change in the numerical value at the end of the command string. A convenient method to do this is to join two strings together. This process is called string concatenation and as expected, C++ provides the ability to do this. The function of interest is call strcat_s() with a definition of:
char * strcat_s ( char * destination, const char * source );
The parameter destination is the first null-terminated string and the parameter source is the null terminated string that is to be appended to destination. In the case of the OUSB Board command, the destination string would be set to "ousb –r io PORTB " and then the character value of '42' would be added. Using the ‘OUSB_Read_Write_Functions.cpp’ file from the EEET2246 Canvas shell as a reference, write a small application that creates the complete command string that would be sent to the OUSB Board to increment the LEDs sequentially from 0 to 10 and display it on the console window. (As an extra task you may want to write it out to the OUSB Board or periodicall check the portb.txt file if using the simulator).
Note that you will also need to consider the function _itoa_s() to convert the number to write to a character. Place a screenshot and short explanation in your report of how the concatenation functions using a sample piece of text. Ensure that you indicate (and include) the contents of the null-terminated string in your screenshots. [2 marks]
6. Another common task is to compare two null-terminated strings to confirm that they are identical. Unlike numerical data, the equivalence ( == ) operator cannot be used. To compare null-terminated strings the function strcmp() can be utilised. Using the reference website http://www.cplusplus.com/reference/ determine the function definition. Note that this function will return zero if the null-terminated strings are equal. Set the command line input argument to the letter ‘a’ and write a small program using strcmp() to determine if the character is indeed an 'a'. To create the null-terminated string to compare against you can use the following code:
const char letterA[2] = {'a','\0'};
Code CPP file Required & Explanation
7. Another common task when writing software that controls hardware like the OUSB Board is the need to read data from the device as well as write data to it within the same program. The OUSB Board has a set of 8 DIP switches that are connected to PORTC of the ATmega32 microprocessor on the OUSB board. These switches can be set to 256 discrete values (0 to 255) as there are 8 switches in total. You should familiarise yourself with the OUSB board reference manual and modify a version of pipe code in the ‘OUSB_Read_Write_Functions.cpp’ file with the correct command to read the values from the 8 DIP switches. Thereafter, write a small program that displays the value of the DIP switches on the LEDs connected to PORTB (or within the portb.txt file if using the simulator). You program should update the values of LEDs to reflect changes made to the switches in real time, therefore you might consider using an infinite loop to perform the read/write operations. Submit your code and provide a screenshot of the test values being used and the corresponding update of the virtual LEDs.
Note: If you want to slow down your loop you can include the Sleep() function, which will make your program pause for x number of milliseconds. You must add the #include <windows.h> statement to the top of your program and write the following line within the for loop:
Sleep(1000); // pause the program for 1 second (1000 ms)
Remember that you should not use such a statement within your Laboratory Code Submission assessments. [4 marks]
Once you have finished these tasks you are free to start working on your Laboratory Code Submission 2 solution.
Make sure that you download and read the Laboratory Code Submission 2 proforma .cpp file which is available on Canvas. It is suggested that you use the Six Basic Steps of Program Design discussed during the lectures and tutorials:
1. Statement of the Problem
  • Requirements Analysis
  • Determine aims of program, input and output requirements, and specifications
2. Initial Design
  • Overall program operation and sequence using flowcharts, block diagrams, also develop initial test plan
3. Detailed Design
  • Write pseudocode (e.g. structured English) based on the flowcharts or block diagrams you designed above.
4. Coding
  • Write the program
5. Test and Debug
  • Thoroughly test the program, debug to locate and correct faults
6. Refinement
  • Ensure program meets customer specifications
Part A - Summary of Code Expressions:

Week 6 laboratory tasks would have most likely exposed you to the following code expressions/statements:

Expression
Brief description
if ( condition )
{
// execute these statement only
// if condition is true
}
if statements provided the ability to control the flow of your program. If the expression in the brackets is true or NOT zero, then the expressions within the block of code (code inside the {} braces) will be executed.
[n]
The [] operators allow you to access the contents of an array via an index value, n. Eg. argv[1] will access the first character of first argument passed to the program via the command line argument. argv[0] will be the name of your program.
_popen()
Open a communication pipe to another process.
Must be called before the pipe is accessed.
_pclose()
Close an existing communication pipe that was previously opened via the _popen() command.
==
Is the equality operator, which is used in condition expressions such as if statements or for loops.
++
Increment operator. i++ is equivalent to i = i + 1;
for ( init; condition; increment )
{
// statement(s) to execute if
// condition is true.
}
A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times. Once the condition expression resolves as NOT true the loop will cease to execute.
strcpy_s(char * destination, char * source); Copy a null-terminated string from ‘source’ to ‘destination’.
_itoa_s(int value, char * str, int base)
C function used to convert an integer in value into a null-terminated string which is stored in str. The value of base determines that numerical base to interpret the integer as. Note that base 10 is considered to be decimal.
int atoi(char * str);
C function used to parses a C string str, interpreting its content as a whole number and returns its value as an integer.

Part B - Summary of Code Expressions:

Week 7 laboratory tasks would have most likely exposed you to the following code expressions/statements:
Expression
Brief description
if ( condition )
{
// execute these statement only
// if condition is true
}
if statements provided the ability to control the flow of your program. If the expression in the brackets is true or NOT zero, then the expressions within the block of code (code inside the {} braces) will be executed.
[n]
The [] operators allow you to access the contents of an array via an index value, n. Eg. argv[1] will access the first character of first argument passed to the program via the command line argument. argv[0] will be the name of your program.
_popen()
Open a communication pipe to another process. Mustbe called before the pipe is accessed.
_pclose()
Close an existing communication pipe that was previously opened via the _popen() command.
==
Is the equality operator, which is used in condition expressions such as if statements or for loops.
++
Increment operator. i++ is equivalent to i = i + 1;
for ( init; condition; increment )
{
// statement(s) to execute if
// condition is true.
}
A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times. Once the condition expression resolves as NOT true the loop will cease to execute.
strcpy_s(char * destination, char *
source);
Copy a null-terminated string from ‘source’ to ‘destination’.
_itoa_s(int value, char * str, int base)
C function used to convert an integer in value into a null-terminated string which is stored in str. The value of base determines that numerical base to interpret the integer as. Note that base 10 is considered to be decimal.
int atoi(char * str);
C function used to parses a C string str, interpreting its content as a whole number and returns its value as an integer.
int isdigit ( int c );
C function to determine if the value of c is a digit (0 – 9). Returns a non-zero value if true.
char * strcat_s ( char * destination, const char * source ); C function to join the null-terminated string in destination to that of source. The resultant string is stored in destination.
int strcmp ( const char * str1, const char * str2 ); C function to compare two null-terminated strings str1 to str2 and returns zero if they are equal

发表评论

电子邮件地址不会被公开。 必填项已用*标注