SlideShare ist ein Scribd-Unternehmen logo
1 von 11
// [File name] // [Your name] // [Date] // [Version] //
[Description] // THIS CODE COMPILES AS IS - I
RECOMMEND SAVING YOUR PROGRESS REGULARLY. //
EVEN IF YOU DO NOT COMPLETE A FUNCTION BEFORE
TURNING IT IN IT WILL // STILL COMPILE. IF YOU
COMPLETE 99% OF THE FUNCTIONALITY AND THEN //
CREATE AN ERROR THAT WON'T COMPILE YOU WILL
GET A 0% GRADE. #include <iostream> // Function
Prototypes // ancillary functions void SeedRand(int x); //
Array testing void InitializeArray(int a[], int arraySize); void
PrintArray(int a[], int arraySize); bool Contains(int a[], int
arraySize, int testVal); void BubbleSort(int a[], int arraySize);
int SumArray(int a[], int arraySize); int Largest(int a[], int
arraySize); int Smallest(int a[], int arraySize); double
Average(int a[], int arraySize); void ReverseArray(int a[], int
arraySize); // multi-dimensional arrays void
InitializeTemperatures(int ma[][2], int xSize); void
PrintArray(double ma[][2], int xSize); //[BEGIN MAIN] // DO
NOT REMOVE THIS LINE int main() { // This entire main()
function will be deleted // during the assessment and replaced
with // another main() function that tests your code. //
Develop code here to test your functions // You may use
std::cout in any tests you develop // DO NOT put std::cout
statements in any of the // provided function skeletons unless
specificaly asked for // Here is a quick array to get you
started. // This size may change! // Make sure your functions
work for any array size. const int ARRAY_SIZE = 20; int
a[ARRAY_SIZE]; // Start here // Call your functions and test
their output // Here is an example SeedRand(0); // Only call
this ONCE InitializeArray(a, ARRAY_SIZE); std::cout <<
"My array="; PrintArray(a, ARRAY_SIZE); std::cout << "
"; // Did it work? std::cout << "Press ENTER";
std::cin.ignore(); std::cin.get(); return 0; } //[END MAIN] //
DO NOT REMOVE THIS LINE // Implement all of the
following functions // DO NOT put any std::cout statements
unless directly specified // DO NOT change their signatures
void SeedRand(int x) { // Seed the random number generator
with x } void InitializeArray(int a[], int arraySize) { //
Develop an algorithm that inserts random numbers // between
1 and 100 into a[] // hint: use rand() } void PrintArray(int a[],
int arraySize) { // print the array using cout // leave 1 space
in-between each integer // Example: if the array holds { 1, 2, 3
} // This function should print: 1 2 3 // It is ok to have a
dangling space at the end } bool Contains(int a[], int arraySize,
int testVal) { bool contains = false; // Develop a linear search
algorithm that tests // whether the array contains testVal
return contains; } void BubbleSort(int a[], int arraySize) { //
Develop an algorithm that performs the bubble sort } int
SumArray(int a[], int arraySize) { int sum = 0; // Develop an
algorithm that sums the entire array // and RETURNS the
result return sum; } int Largest(int a[], int arraySize) { int
largest = a[0]; // Develop an algorithm to figure out the largest
value return largest; } int Smallest(int a[], int arraySize) {
int smallest = a[0]; // Develop an algorithm to figure out the
smallest value return smallest; } double Average(int a[], int
arraySize) { double average = 0; // Develop an algorithm to
figure out the average INCLUDING decimals // You might
find your previous SumArray function useful return average; }
void ReverseArray(int a[], int arraySize) { // Develop an
algorithm to flip the array backwards // You might need some
temporary storage // I wonder if you could just copy the array
into a new one // and then copy over the old values 1 by 1
from the back } void InitializeTemperatures(double ma[][2], int
xSize) { // Develop an algorithm that inserts random numbers
// between 1 and 100 into a[i][0] // hint: use rand() // These
random numbers represent a temperature in Fahrenheit // Then,
store the Celsius equivalents into a[i][1] } void
PrintArray(double ma[][2], int xSize) { // print the multi-
dimensional array using cout // Each x-y pair should be printed
like so: [x,y] // All pairs should be printed on one line with no
spaces // Example: [x0,y0][x1,y1][x2,y2] ... }
Solution
// [File name]
// [Your name]
// [Date]
// [Version]
// [Description]
// THIS CODE COMPILES AS IS - I RECOMMEND SAVING
YOUR PROGRESS REGULARLY.
// EVEN IF YOU DO NOT COMPLETE A FUNCTION
BEFORE TURNING IT IN IT WILL
// STILL COMPILE. IF YOU COMPLETE 99% OF THE
FUNCTIONALITY AND THEN
// CREATE AN ERROR THAT WON'T COMPILE YOU WILL
GET A 0% GRADE.
#include <iostream>
#include <time.h>
using namespace std;
// Function Prototypes
// ancillary functions
void SeedRand(int x);
// Array testing
void InitializeArray(int a[], int arraySize);
void PrintArray(int a[], int arraySize);
bool Contains(int a[], int arraySize, int testVal);
void BubbleSort(int a[], int arraySize);
int SumArray(int a[], int arraySize);
int Largest(int a[], int arraySize);
int Smallest(int a[], int arraySize);
double Average(int a[], int arraySize);
void ReverseArray(int a[], int arraySize);
// multi-dimensional arrays
void InitializeTemperatures(int ma[][2], int xSize);
void PrintArray(double ma[][2], int xSize);
//[BEGIN MAIN] // DO NOT REMOVE THIS LINE
int main()
{
// This entire main() function will be deleted
// during the assessment and replaced with
// another main() function that tests your code.
// Develop code here to test your functions
// You may use std::cout in any tests you develop
// DO NOT put std::cout statements in any of the
// provided function skeletons unless specificaly asked for
// Here is a quick array to get you started.
// This size may change!
// Make sure your functions work for any array size.
const int ARRAY_SIZE = 20;
int a[ARRAY_SIZE];
// Start here
// Call your functions and test their output
// Here is an example
SeedRand(0); // Only call this ONCE
InitializeArray(a, ARRAY_SIZE);
std::cout << "My array=";
PrintArray(a, ARRAY_SIZE);
std::cout << " ";
// Did it work?
std::cout << "Press ENTER";
std::cin.ignore();
std::cin.get();
return 0;
}
//[END MAIN] // DO NOT REMOVE THIS LINE
// Implement all of the following functions
// DO NOT put any std::cout statements unless directly
specified
// DO NOT change their signatures
void SeedRand(int x)
{
// Seed the random number generator with x
srand (x);
}
void InitializeArray(int a[], int arraySize)
{
// Develop an algorithm that inserts random numbers
// between 1 and 100 into a[]
// hint: use rand()
for(int i=0;i<arraySize;i++)
{
a[i]=rand() % 100 + 1;
}
}
void PrintArray(int a[], int arraySize)
{
// print the array using cout
// leave 1 space in-between each integer
// Example: if the array holds { 1, 2, 3 }
// This function should print: 1 2 3
// It is ok to have a dangling space at the end
for(int i=0;i<arraySize;i++)
{
cout<<a[i]<<" ";
}
}
bool Contains(int a[], int arraySize, int testVal)
{
bool contains = false;
// Develop a linear search algorithm that tests
// whether the array contains testVal
for(int i=0;i<arraySize;i++)
{
if(a[i]==testVal)
{
contains=true;
break;
}
}
return contains;
}
void BubbleSort(int a[], int arraySize)
{
// Develop an algorithm that performs the bubble sort
int temp;
for(int i=1;i<arraySize;++i)
{
for(int j=0;j<(arraySize-i);++j)
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
int SumArray(int a[], int arraySize)
{
int sum = 0;
// Develop an algorithm that sums the entire array
// and RETURNS the result
for(int i=0;i<arraySize;i++)
{
sum+=a[i];
}
return sum;
}
int Largest(int a[], int arraySize)
{
int largest = a[0];
// Develop an algorithm to figure out the largest value
for(int i=0;i<arraySize;i++)
{
if(a[i]>largest)
largest=a[i];
}
return largest;
}
int Smallest(int a[], int arraySize)
{
int smallest = a[0];
// Develop an algorithm to figure out the smallest value
for(int i=0;i<<arraySize;i++)
{
if(a[i]<smallest)
smallest=a[i];
}
return smallest;
}
double Average(int a[], int arraySize)
{
double average = 0;
// Develop an algorithm to figure out the average INCLUDING
decimals
// You might find your previous SumArray function useful
for(int i=0;i<arraySize;i++)
{
average+=a[i];
}
average/=arraySize;
return average;
}
void ReverseArray(int a[], int arraySize)
{
// Develop an algorithm to flip the array backwards
// You might need some temporary storage
// I wonder if you could just copy the array into a new one
// and then copy over the old values 1 by 1 from the back
int temp;
for (int i = 0; i < (arraySize / 2); i++)
{
temp = a[i];
a[i] = a[(arraySize - 1) - i];
a[(arraySize - 1) - i] = temp;
}
}
void InitializeTemperatures(double ma[][2], int xSize)
{
// Develop an algorithm that inserts random numbers
// between 1 and 100 into a[i][0]
// hint: use rand()
// These random numbers represent a temperature in Fahrenheit
// Then, store the Celsius equivalents into a[i][1]
for(int i=0;i<xSize;i++)
{
ma[i][0]=rand()%100+1;
ma[i][1]=(5/9) * (ma[i][0] + 32);
}
}
void PrintArray(double ma[][2], int xSize)
{
// print the multi-dimensional array using cout
// Each x-y pair should be printed like so: [x,y]
// All pairs should be printed on one line with no spaces
// Example: [x0,y0][x1,y1][x2,y2] ...
for(int i=0;i<xSize;i++)
{
cout<<"["<<ma[i][0]<<","<<ma[i][1]<<"]";
}
}

Weitere ähnliche Inhalte

Ähnlich wie [File name] [Your name] [Date] [Version] [Descriptio.docx

Operator Overloading & Type Conversions
Operator Overloading & Type ConversionsOperator Overloading & Type Conversions
Operator Overloading & Type ConversionsRokonuzzaman Rony
 
C++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfC++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfyamew16788
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfinfo309708
 
C-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression CalculatorC-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression CalculatorNeeraj Kaushik
 
Merge Sort java with a few details, please include comments if possi.pdf
Merge Sort java with a few details, please include comments if possi.pdfMerge Sort java with a few details, please include comments if possi.pdf
Merge Sort java with a few details, please include comments if possi.pdffeelinggifts
 
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0Yaser Zhian
 
check the modifed code now you will get all operations done.termin.pdf
check the modifed code now you will get all operations done.termin.pdfcheck the modifed code now you will get all operations done.termin.pdf
check the modifed code now you will get all operations done.termin.pdfangelfragranc
 
Write a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdfWrite a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdfmohdjakirfb
 
LECTURE 3 LOOPS, ARRAYS.pdf
LECTURE 3 LOOPS, ARRAYS.pdfLECTURE 3 LOOPS, ARRAYS.pdf
LECTURE 3 LOOPS, ARRAYS.pdfSHASHIKANT346021
 
Operator overloading in c++ is the most required.
Operator overloading in c++ is the most required.Operator overloading in c++ is the most required.
Operator overloading in c++ is the most required.iammukesh1075
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxssuser454af01
 
LECTURE 3 LOOPS, ARRAYS.pdf
LECTURE 3 LOOPS, ARRAYS.pdfLECTURE 3 LOOPS, ARRAYS.pdf
LECTURE 3 LOOPS, ARRAYS.pdfShashikantSathe3
 
C++ course start
C++ course startC++ course start
C++ course startNet3lem
 
Synapse india dotnet development overloading operater part 3
Synapse india dotnet development overloading operater part 3Synapse india dotnet development overloading operater part 3
Synapse india dotnet development overloading operater part 3Synapseindiappsdevelopment
 
C-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdfC-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdfherminaherman
 

Ähnlich wie [File name] [Your name] [Date] [Version] [Descriptio.docx (20)

Operator Overloading & Type Conversions
Operator Overloading & Type ConversionsOperator Overloading & Type Conversions
Operator Overloading & Type Conversions
 
C++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfC++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdf
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
 
C-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression CalculatorC-Sharp Arithmatic Expression Calculator
C-Sharp Arithmatic Expression Calculator
 
Js hacks
Js hacksJs hacks
Js hacks
 
Merge Sort java with a few details, please include comments if possi.pdf
Merge Sort java with a few details, please include comments if possi.pdfMerge Sort java with a few details, please include comments if possi.pdf
Merge Sort java with a few details, please include comments if possi.pdf
 
Templates
TemplatesTemplates
Templates
 
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0
 
PSI 3 Integration
PSI 3 IntegrationPSI 3 Integration
PSI 3 Integration
 
check the modifed code now you will get all operations done.termin.pdf
check the modifed code now you will get all operations done.termin.pdfcheck the modifed code now you will get all operations done.termin.pdf
check the modifed code now you will get all operations done.termin.pdf
 
Write a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdfWrite a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdf
 
LECTURE 3 LOOPS, ARRAYS.pdf
LECTURE 3 LOOPS, ARRAYS.pdfLECTURE 3 LOOPS, ARRAYS.pdf
LECTURE 3 LOOPS, ARRAYS.pdf
 
Operator overloading in c++ is the most required.
Operator overloading in c++ is the most required.Operator overloading in c++ is the most required.
Operator overloading in c++ is the most required.
 
lecture12.ppt
lecture12.pptlecture12.ppt
lecture12.ppt
 
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
 
LECTURE 3 LOOPS, ARRAYS.pdf
LECTURE 3 LOOPS, ARRAYS.pdfLECTURE 3 LOOPS, ARRAYS.pdf
LECTURE 3 LOOPS, ARRAYS.pdf
 
C++ course start
C++ course startC++ course start
C++ course start
 
Synapse india dotnet development overloading operater part 3
Synapse india dotnet development overloading operater part 3Synapse india dotnet development overloading operater part 3
Synapse india dotnet development overloading operater part 3
 
C-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdfC-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdf
 

Mehr von ShiraPrater50

Read Chapter 3. Answer the following questions1.Wha.docx
Read Chapter 3. Answer the following questions1.Wha.docxRead Chapter 3. Answer the following questions1.Wha.docx
Read Chapter 3. Answer the following questions1.Wha.docxShiraPrater50
 
Read Chapter 15 and answer the following questions 1.  De.docx
Read Chapter 15 and answer the following questions 1.  De.docxRead Chapter 15 and answer the following questions 1.  De.docx
Read Chapter 15 and answer the following questions 1.  De.docxShiraPrater50
 
Read Chapter 2 and answer the following questions1.  List .docx
Read Chapter 2 and answer the following questions1.  List .docxRead Chapter 2 and answer the following questions1.  List .docx
Read Chapter 2 and answer the following questions1.  List .docxShiraPrater50
 
Read chapter 7 and write the book report  The paper should be .docx
Read chapter 7 and write the book report  The paper should be .docxRead chapter 7 and write the book report  The paper should be .docx
Read chapter 7 and write the book report  The paper should be .docxShiraPrater50
 
Read Chapter 7 and answer the following questions1.  What a.docx
Read Chapter 7 and answer the following questions1.  What a.docxRead Chapter 7 and answer the following questions1.  What a.docx
Read Chapter 7 and answer the following questions1.  What a.docxShiraPrater50
 
Read chapter 14, 15 and 18 of the class textbook.Saucier.docx
Read chapter 14, 15 and 18 of the class textbook.Saucier.docxRead chapter 14, 15 and 18 of the class textbook.Saucier.docx
Read chapter 14, 15 and 18 of the class textbook.Saucier.docxShiraPrater50
 
Read Chapter 10 APA FORMAT1. In the last century, what historica.docx
Read Chapter 10 APA FORMAT1. In the last century, what historica.docxRead Chapter 10 APA FORMAT1. In the last century, what historica.docx
Read Chapter 10 APA FORMAT1. In the last century, what historica.docxShiraPrater50
 
Read chapter 7 and write the book report  The paper should b.docx
Read chapter 7 and write the book report  The paper should b.docxRead chapter 7 and write the book report  The paper should b.docx
Read chapter 7 and write the book report  The paper should b.docxShiraPrater50
 
Read Chapter 14 and answer the following questions1.  Explain t.docx
Read Chapter 14 and answer the following questions1.  Explain t.docxRead Chapter 14 and answer the following questions1.  Explain t.docx
Read Chapter 14 and answer the following questions1.  Explain t.docxShiraPrater50
 
Read Chapter 2 first. Then come to this assignment.The first t.docx
Read Chapter 2 first. Then come to this assignment.The first t.docxRead Chapter 2 first. Then come to this assignment.The first t.docx
Read Chapter 2 first. Then come to this assignment.The first t.docxShiraPrater50
 
Journal of Public Affairs Education 515Teaching Grammar a.docx
 Journal of Public Affairs Education 515Teaching Grammar a.docx Journal of Public Affairs Education 515Teaching Grammar a.docx
Journal of Public Affairs Education 515Teaching Grammar a.docxShiraPrater50
 
Learner Guide TLIR5014 Manage suppliers TLIR.docx
 Learner Guide TLIR5014 Manage suppliers TLIR.docx Learner Guide TLIR5014 Manage suppliers TLIR.docx
Learner Guide TLIR5014 Manage suppliers TLIR.docxShiraPrater50
 
Lab 5 Nessus Vulnerability Scan Report © 2012 by Jone.docx
 Lab 5 Nessus Vulnerability Scan Report © 2012 by Jone.docx Lab 5 Nessus Vulnerability Scan Report © 2012 by Jone.docx
Lab 5 Nessus Vulnerability Scan Report © 2012 by Jone.docxShiraPrater50
 
Leveled and Exclusionary Tracking English Learners Acce.docx
 Leveled and Exclusionary Tracking English Learners Acce.docx Leveled and Exclusionary Tracking English Learners Acce.docx
Leveled and Exclusionary Tracking English Learners Acce.docxShiraPrater50
 
Lab 5 Nessus Vulnerability Scan Report © 2015 by Jone.docx
 Lab 5 Nessus Vulnerability Scan Report © 2015 by Jone.docx Lab 5 Nessus Vulnerability Scan Report © 2015 by Jone.docx
Lab 5 Nessus Vulnerability Scan Report © 2015 by Jone.docxShiraPrater50
 
MBA 6941, Managing Project Teams 1 Course Learning Ou.docx
 MBA 6941, Managing Project Teams 1 Course Learning Ou.docx MBA 6941, Managing Project Teams 1 Course Learning Ou.docx
MBA 6941, Managing Project Teams 1 Course Learning Ou.docxShiraPrater50
 
Inventory Decisions in Dells Supply ChainAuthor(s) Ro.docx
 Inventory Decisions in Dells Supply ChainAuthor(s) Ro.docx Inventory Decisions in Dells Supply ChainAuthor(s) Ro.docx
Inventory Decisions in Dells Supply ChainAuthor(s) Ro.docxShiraPrater50
 
It’s Your Choice 10 – Clear Values 2nd Chain Link- Trade-offs .docx
 It’s Your Choice 10 – Clear Values 2nd Chain Link- Trade-offs .docx It’s Your Choice 10 – Clear Values 2nd Chain Link- Trade-offs .docx
It’s Your Choice 10 – Clear Values 2nd Chain Link- Trade-offs .docxShiraPrater50
 
MBA 5101, Strategic Management and Business Policy 1 .docx
 MBA 5101, Strategic Management and Business Policy 1 .docx MBA 5101, Strategic Management and Business Policy 1 .docx
MBA 5101, Strategic Management and Business Policy 1 .docxShiraPrater50
 
MAJOR WORLD RELIGIONSJudaismJudaism (began .docx
 MAJOR WORLD RELIGIONSJudaismJudaism (began .docx MAJOR WORLD RELIGIONSJudaismJudaism (began .docx
MAJOR WORLD RELIGIONSJudaismJudaism (began .docxShiraPrater50
 

Mehr von ShiraPrater50 (20)

Read Chapter 3. Answer the following questions1.Wha.docx
Read Chapter 3. Answer the following questions1.Wha.docxRead Chapter 3. Answer the following questions1.Wha.docx
Read Chapter 3. Answer the following questions1.Wha.docx
 
Read Chapter 15 and answer the following questions 1.  De.docx
Read Chapter 15 and answer the following questions 1.  De.docxRead Chapter 15 and answer the following questions 1.  De.docx
Read Chapter 15 and answer the following questions 1.  De.docx
 
Read Chapter 2 and answer the following questions1.  List .docx
Read Chapter 2 and answer the following questions1.  List .docxRead Chapter 2 and answer the following questions1.  List .docx
Read Chapter 2 and answer the following questions1.  List .docx
 
Read chapter 7 and write the book report  The paper should be .docx
Read chapter 7 and write the book report  The paper should be .docxRead chapter 7 and write the book report  The paper should be .docx
Read chapter 7 and write the book report  The paper should be .docx
 
Read Chapter 7 and answer the following questions1.  What a.docx
Read Chapter 7 and answer the following questions1.  What a.docxRead Chapter 7 and answer the following questions1.  What a.docx
Read Chapter 7 and answer the following questions1.  What a.docx
 
Read chapter 14, 15 and 18 of the class textbook.Saucier.docx
Read chapter 14, 15 and 18 of the class textbook.Saucier.docxRead chapter 14, 15 and 18 of the class textbook.Saucier.docx
Read chapter 14, 15 and 18 of the class textbook.Saucier.docx
 
Read Chapter 10 APA FORMAT1. In the last century, what historica.docx
Read Chapter 10 APA FORMAT1. In the last century, what historica.docxRead Chapter 10 APA FORMAT1. In the last century, what historica.docx
Read Chapter 10 APA FORMAT1. In the last century, what historica.docx
 
Read chapter 7 and write the book report  The paper should b.docx
Read chapter 7 and write the book report  The paper should b.docxRead chapter 7 and write the book report  The paper should b.docx
Read chapter 7 and write the book report  The paper should b.docx
 
Read Chapter 14 and answer the following questions1.  Explain t.docx
Read Chapter 14 and answer the following questions1.  Explain t.docxRead Chapter 14 and answer the following questions1.  Explain t.docx
Read Chapter 14 and answer the following questions1.  Explain t.docx
 
Read Chapter 2 first. Then come to this assignment.The first t.docx
Read Chapter 2 first. Then come to this assignment.The first t.docxRead Chapter 2 first. Then come to this assignment.The first t.docx
Read Chapter 2 first. Then come to this assignment.The first t.docx
 
Journal of Public Affairs Education 515Teaching Grammar a.docx
 Journal of Public Affairs Education 515Teaching Grammar a.docx Journal of Public Affairs Education 515Teaching Grammar a.docx
Journal of Public Affairs Education 515Teaching Grammar a.docx
 
Learner Guide TLIR5014 Manage suppliers TLIR.docx
 Learner Guide TLIR5014 Manage suppliers TLIR.docx Learner Guide TLIR5014 Manage suppliers TLIR.docx
Learner Guide TLIR5014 Manage suppliers TLIR.docx
 
Lab 5 Nessus Vulnerability Scan Report © 2012 by Jone.docx
 Lab 5 Nessus Vulnerability Scan Report © 2012 by Jone.docx Lab 5 Nessus Vulnerability Scan Report © 2012 by Jone.docx
Lab 5 Nessus Vulnerability Scan Report © 2012 by Jone.docx
 
Leveled and Exclusionary Tracking English Learners Acce.docx
 Leveled and Exclusionary Tracking English Learners Acce.docx Leveled and Exclusionary Tracking English Learners Acce.docx
Leveled and Exclusionary Tracking English Learners Acce.docx
 
Lab 5 Nessus Vulnerability Scan Report © 2015 by Jone.docx
 Lab 5 Nessus Vulnerability Scan Report © 2015 by Jone.docx Lab 5 Nessus Vulnerability Scan Report © 2015 by Jone.docx
Lab 5 Nessus Vulnerability Scan Report © 2015 by Jone.docx
 
MBA 6941, Managing Project Teams 1 Course Learning Ou.docx
 MBA 6941, Managing Project Teams 1 Course Learning Ou.docx MBA 6941, Managing Project Teams 1 Course Learning Ou.docx
MBA 6941, Managing Project Teams 1 Course Learning Ou.docx
 
Inventory Decisions in Dells Supply ChainAuthor(s) Ro.docx
 Inventory Decisions in Dells Supply ChainAuthor(s) Ro.docx Inventory Decisions in Dells Supply ChainAuthor(s) Ro.docx
Inventory Decisions in Dells Supply ChainAuthor(s) Ro.docx
 
It’s Your Choice 10 – Clear Values 2nd Chain Link- Trade-offs .docx
 It’s Your Choice 10 – Clear Values 2nd Chain Link- Trade-offs .docx It’s Your Choice 10 – Clear Values 2nd Chain Link- Trade-offs .docx
It’s Your Choice 10 – Clear Values 2nd Chain Link- Trade-offs .docx
 
MBA 5101, Strategic Management and Business Policy 1 .docx
 MBA 5101, Strategic Management and Business Policy 1 .docx MBA 5101, Strategic Management and Business Policy 1 .docx
MBA 5101, Strategic Management and Business Policy 1 .docx
 
MAJOR WORLD RELIGIONSJudaismJudaism (began .docx
 MAJOR WORLD RELIGIONSJudaismJudaism (began .docx MAJOR WORLD RELIGIONSJudaismJudaism (began .docx
MAJOR WORLD RELIGIONSJudaismJudaism (began .docx
 

Kürzlich hochgeladen

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 

Kürzlich hochgeladen (20)

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 

[File name] [Your name] [Date] [Version] [Descriptio.docx

  • 1. // [File name] // [Your name] // [Date] // [Version] // [Description] // THIS CODE COMPILES AS IS - I RECOMMEND SAVING YOUR PROGRESS REGULARLY. // EVEN IF YOU DO NOT COMPLETE A FUNCTION BEFORE TURNING IT IN IT WILL // STILL COMPILE. IF YOU COMPLETE 99% OF THE FUNCTIONALITY AND THEN // CREATE AN ERROR THAT WON'T COMPILE YOU WILL GET A 0% GRADE. #include <iostream> // Function Prototypes // ancillary functions void SeedRand(int x); // Array testing void InitializeArray(int a[], int arraySize); void PrintArray(int a[], int arraySize); bool Contains(int a[], int arraySize, int testVal); void BubbleSort(int a[], int arraySize); int SumArray(int a[], int arraySize); int Largest(int a[], int arraySize); int Smallest(int a[], int arraySize); double Average(int a[], int arraySize); void ReverseArray(int a[], int arraySize); // multi-dimensional arrays void InitializeTemperatures(int ma[][2], int xSize); void PrintArray(double ma[][2], int xSize); //[BEGIN MAIN] // DO NOT REMOVE THIS LINE int main() { // This entire main() function will be deleted // during the assessment and replaced with // another main() function that tests your code. // Develop code here to test your functions // You may use std::cout in any tests you develop // DO NOT put std::cout statements in any of the // provided function skeletons unless specificaly asked for // Here is a quick array to get you started. // This size may change! // Make sure your functions work for any array size. const int ARRAY_SIZE = 20; int a[ARRAY_SIZE]; // Start here // Call your functions and test their output // Here is an example SeedRand(0); // Only call this ONCE InitializeArray(a, ARRAY_SIZE); std::cout << "My array="; PrintArray(a, ARRAY_SIZE); std::cout << " "; // Did it work? std::cout << "Press ENTER"; std::cin.ignore(); std::cin.get(); return 0; } //[END MAIN] // DO NOT REMOVE THIS LINE // Implement all of the following functions // DO NOT put any std::cout statements
  • 2. unless directly specified // DO NOT change their signatures void SeedRand(int x) { // Seed the random number generator with x } void InitializeArray(int a[], int arraySize) { // Develop an algorithm that inserts random numbers // between 1 and 100 into a[] // hint: use rand() } void PrintArray(int a[], int arraySize) { // print the array using cout // leave 1 space in-between each integer // Example: if the array holds { 1, 2, 3 } // This function should print: 1 2 3 // It is ok to have a dangling space at the end } bool Contains(int a[], int arraySize, int testVal) { bool contains = false; // Develop a linear search algorithm that tests // whether the array contains testVal return contains; } void BubbleSort(int a[], int arraySize) { // Develop an algorithm that performs the bubble sort } int SumArray(int a[], int arraySize) { int sum = 0; // Develop an algorithm that sums the entire array // and RETURNS the result return sum; } int Largest(int a[], int arraySize) { int largest = a[0]; // Develop an algorithm to figure out the largest value return largest; } int Smallest(int a[], int arraySize) { int smallest = a[0]; // Develop an algorithm to figure out the smallest value return smallest; } double Average(int a[], int arraySize) { double average = 0; // Develop an algorithm to figure out the average INCLUDING decimals // You might find your previous SumArray function useful return average; } void ReverseArray(int a[], int arraySize) { // Develop an algorithm to flip the array backwards // You might need some temporary storage // I wonder if you could just copy the array into a new one // and then copy over the old values 1 by 1 from the back } void InitializeTemperatures(double ma[][2], int xSize) { // Develop an algorithm that inserts random numbers // between 1 and 100 into a[i][0] // hint: use rand() // These random numbers represent a temperature in Fahrenheit // Then, store the Celsius equivalents into a[i][1] } void PrintArray(double ma[][2], int xSize) { // print the multi- dimensional array using cout // Each x-y pair should be printed like so: [x,y] // All pairs should be printed on one line with no spaces // Example: [x0,y0][x1,y1][x2,y2] ... }
  • 3. Solution // [File name] // [Your name] // [Date] // [Version] // [Description] // THIS CODE COMPILES AS IS - I RECOMMEND SAVING YOUR PROGRESS REGULARLY. // EVEN IF YOU DO NOT COMPLETE A FUNCTION BEFORE TURNING IT IN IT WILL // STILL COMPILE. IF YOU COMPLETE 99% OF THE FUNCTIONALITY AND THEN // CREATE AN ERROR THAT WON'T COMPILE YOU WILL GET A 0% GRADE. #include <iostream> #include <time.h> using namespace std; // Function Prototypes // ancillary functions void SeedRand(int x);
  • 4. // Array testing void InitializeArray(int a[], int arraySize); void PrintArray(int a[], int arraySize); bool Contains(int a[], int arraySize, int testVal); void BubbleSort(int a[], int arraySize); int SumArray(int a[], int arraySize); int Largest(int a[], int arraySize); int Smallest(int a[], int arraySize); double Average(int a[], int arraySize); void ReverseArray(int a[], int arraySize); // multi-dimensional arrays void InitializeTemperatures(int ma[][2], int xSize); void PrintArray(double ma[][2], int xSize); //[BEGIN MAIN] // DO NOT REMOVE THIS LINE int main() { // This entire main() function will be deleted // during the assessment and replaced with // another main() function that tests your code. // Develop code here to test your functions // You may use std::cout in any tests you develop // DO NOT put std::cout statements in any of the // provided function skeletons unless specificaly asked for // Here is a quick array to get you started. // This size may change!
  • 5. // Make sure your functions work for any array size. const int ARRAY_SIZE = 20; int a[ARRAY_SIZE]; // Start here // Call your functions and test their output // Here is an example SeedRand(0); // Only call this ONCE InitializeArray(a, ARRAY_SIZE); std::cout << "My array="; PrintArray(a, ARRAY_SIZE); std::cout << " "; // Did it work? std::cout << "Press ENTER"; std::cin.ignore(); std::cin.get(); return 0; } //[END MAIN] // DO NOT REMOVE THIS LINE // Implement all of the following functions // DO NOT put any std::cout statements unless directly specified // DO NOT change their signatures void SeedRand(int x) {
  • 6. // Seed the random number generator with x srand (x); } void InitializeArray(int a[], int arraySize) { // Develop an algorithm that inserts random numbers // between 1 and 100 into a[] // hint: use rand() for(int i=0;i<arraySize;i++) { a[i]=rand() % 100 + 1; } } void PrintArray(int a[], int arraySize) { // print the array using cout // leave 1 space in-between each integer // Example: if the array holds { 1, 2, 3 } // This function should print: 1 2 3 // It is ok to have a dangling space at the end for(int i=0;i<arraySize;i++) { cout<<a[i]<<" "; } }
  • 7. bool Contains(int a[], int arraySize, int testVal) { bool contains = false; // Develop a linear search algorithm that tests // whether the array contains testVal for(int i=0;i<arraySize;i++) { if(a[i]==testVal) { contains=true; break; } } return contains; } void BubbleSort(int a[], int arraySize) { // Develop an algorithm that performs the bubble sort int temp; for(int i=1;i<arraySize;++i) { for(int j=0;j<(arraySize-i);++j) if(a[j]>a[j+1]) { temp=a[j];
  • 8. a[j]=a[j+1]; a[j+1]=temp; } } } int SumArray(int a[], int arraySize) { int sum = 0; // Develop an algorithm that sums the entire array // and RETURNS the result for(int i=0;i<arraySize;i++) { sum+=a[i]; } return sum; } int Largest(int a[], int arraySize) { int largest = a[0]; // Develop an algorithm to figure out the largest value for(int i=0;i<arraySize;i++) { if(a[i]>largest) largest=a[i]; }
  • 9. return largest; } int Smallest(int a[], int arraySize) { int smallest = a[0]; // Develop an algorithm to figure out the smallest value for(int i=0;i<<arraySize;i++) { if(a[i]<smallest) smallest=a[i]; } return smallest; } double Average(int a[], int arraySize) { double average = 0; // Develop an algorithm to figure out the average INCLUDING decimals // You might find your previous SumArray function useful for(int i=0;i<arraySize;i++) { average+=a[i]; } average/=arraySize; return average;
  • 10. } void ReverseArray(int a[], int arraySize) { // Develop an algorithm to flip the array backwards // You might need some temporary storage // I wonder if you could just copy the array into a new one // and then copy over the old values 1 by 1 from the back int temp; for (int i = 0; i < (arraySize / 2); i++) { temp = a[i]; a[i] = a[(arraySize - 1) - i]; a[(arraySize - 1) - i] = temp; } } void InitializeTemperatures(double ma[][2], int xSize) { // Develop an algorithm that inserts random numbers // between 1 and 100 into a[i][0] // hint: use rand() // These random numbers represent a temperature in Fahrenheit // Then, store the Celsius equivalents into a[i][1] for(int i=0;i<xSize;i++) { ma[i][0]=rand()%100+1;
  • 11. ma[i][1]=(5/9) * (ma[i][0] + 32); } } void PrintArray(double ma[][2], int xSize) { // print the multi-dimensional array using cout // Each x-y pair should be printed like so: [x,y] // All pairs should be printed on one line with no spaces // Example: [x0,y0][x1,y1][x2,y2] ... for(int i=0;i<xSize;i++) { cout<<"["<<ma[i][0]<<","<<ma[i][1]<<"]"; } }