This is a DrRacket problem formerly PLT Scheme Exercise Writ

This is a DrRacket problem (formerly PLT Scheme)

Exercise: Write a function that takes as input a natural number, n, for
the size of a vector and that returns a vector of size n initialized
with the first n odd numbers.

Solution

vector getVectorOddNumbers(size_t size) { vector v(size); size_t i = 1; size_t count = 1; for( i = 1; count <= size ; i+=2) { v.push_back(i); count++; } return v; }
This is a DrRacket problem (formerly PLT Scheme) Exercise: Write a function that takes as input a natural number, n, for the size of a vector and that returns a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site