Smith university of st thomas minnesota 8 sum of a

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: with N elements int sumk (int k, int n) { int i; // index for the for loop int t; // total of the sum t = 0; for (i = 0; i < n; i++) { t = t + k[i]; } return t; } March 2005 R. Smith - University of St Thomas - Minnesota 9 Exam Strategy If you don't know what to do Look at the Cheat Sheet Find something about the problem Once you've answered a problem Look up the specifics on the Cheat Sheet Be sure you got the syntax correct Be sure you used the right operators and functions Use "=" for assignment. Use "==" for `if' and `while' March 2005 R. Smith - University of St Thomas - Minnesota 10 Matlab Functions Syntax: function answer = name ( arguments ) % comment on how to use it statements ; File name.m must match function name List of zero or more arguments separated by commas Must set answer to legitimate value Executes statements till the end of the function file Exam will have `single result' functions (like C) March 2005 R. Smith - University of St Thomas - Minnesota 11 Matlab IF/Else Typ...
View Full Document

Ask a homework question - tutors are online