ABCs_iteration - % perfect squares between 1 and N...

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

View Full Document Right Arrow Icon
function [A B] = ABCs_iteration(Z,N) % % DO NOT CHANGE THE FUNCTION HEADER (the first line of code) % % a) for loops. Fix the following for loop so that A is the vector Z in % reverse order. Replace every ? with the necessary code. You must utilize % the for loop to receive credit. % A=[]; for ind=1:length(Z) % change this line A=[Z(ind) A]; % change this line end e % b) while loops. Use the following while loop to count the number of
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % perfect squares between 1 and N inclusive. Store your answer in the % variable B. Replace every ? with the necessary code. You must utilize % this while loop to receive any credit. % num = 1; B = 0; while num<=N % change this line if mod(sqrt(num),1)==0 % change this line (it finds perfect squares) B=B+1; end num = num+1; end...
View Full Document

This note was uploaded on 10/22/2009 for the course CS 1371 taught by Professor Stallworth during the Fall '08 term at Georgia Institute of Technology.

Ask a homework question - tutors are online