lab13 - } void printValues(int array,int first, int last) {

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

View Full Document Right Arrow Icon
#include <iostream> using namespace std; u void printValues(int[],int,int); int Position(int[],int, int, int); i int main() { int first=0; int last=5; int number; int array[6]={5,4,8,7,3,1}; i printValues(array,first,last); p cout<<"Which number in the array do you want the position of?"<<endl; cin>>number; c cout<<"Position:"<<Position(array,first,last,number)<<endl; c return 0;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } void printValues(int array,int first, int last) { if(first&lt;=last) { cout&lt;&lt;array[first]&lt;&lt;endl; printValues(array,first+1,last); } } int Position(int array, int first, int last, int number) { if(first&lt;=last) { if(array[first]!=number) Position(array,first+1,last,number); P else return first+1; } if(first&gt;last) return 0; }...
View Full Document

This note was uploaded on 04/25/2010 for the course CECS CIS 150 taught by Professor L.tsui during the Fall '07 term at University of Michigan-Dearborn.

Ask a homework question - tutors are online