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

Programming With Mathcad Prime 9

The document provides instructions for writing a program in Mathcad to calculate the average of terms in a list. It describes 5 steps: 1) Define a local variable "sum" to track the running total. 2) Create a for loop to iterate through the list. 3) Complete the for loop template by specifying the counter "count" and range from 0 to the length of the list minus 1. 4) Inside the for loop, add each term to the running total variable "sum". 5) After the for loop, divide the total by the number of terms to calculate the average.

Uploaded by

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

Programming With Mathcad Prime 9

The document provides instructions for writing a program in Mathcad to calculate the average of terms in a list. It describes 5 steps: 1) Define a local variable "sum" to track the running total. 2) Create a for loop to iterate through the list. 3) Complete the for loop template by specifying the counter "count" and range from 0 to the length of the list minus 1. 4) Inside the for loop, add each term to the running total variable "sum". 5) After the for loop, divide the total by the number of terms to calculate the average.

Uploaded by

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

Step 3: Define a local variable to keep track of the sum of the terms in List

Type sum in the placeholder on the second line of the program

Left-click on the Programming menu and then left-click on  to insert a Local Assignment symbol

Type 0 and hit Enter to add a new line to the function definition

Step 4: Create a for loop in the program to calculate the average of the terms in List

With the blue cursor in the placeholder on the third line Left-Click on the Programming icon

Left-Click on for in the Programming toolbar. Mathcad will insert a template for defining a for loop

The for loop template has placeholders


for the name of the counter variable, the
range of values for the counter, and the
body of the loop. The body can be one
or more lines.

Step 5: Complete the values in the template for the for loop

In the first placeholder type count, the name given to our local variable for controlling the loop

Create a range variable: In the second placeholder type 0,

Mathcad will insert a template for a range variable as shown below:

In the first empty placeholder for the range variable type 1

In the second placeholder for the range variable type Terms - 1

Left-Click in the placeholder for the body of the for loop

Important Note: The list of terms to be averaged will


be passed to the program as an nx1 matrix, so count
will also be used as a matrix subscript to refer to
each element in the matrix. By default, Mathcad
defines the first position in an array as position 0.

Programming with Mathcad Prime | pg. 7

You might also like