SlideShare a Scribd company logo
1 of 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]<<"]";
}
}

More Related Content

Similar to [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
 

Similar to [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
 
lecture12.ppt
lecture12.pptlecture12.ppt
lecture12.ppt
 
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.
 
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
 

More from 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
 

More from 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
 

Recently uploaded

[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online PresentationGDSCYCCE
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfmstarkes24
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...Sayali Powar
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesRased Khan
 
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Celine George
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Celine George
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdfVikramadityaRaj
 
How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17Celine George
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff17thcssbs2
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024CapitolTechU
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17Celine George
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxjmorse8
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxJenilouCasareno
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...Nguyen Thanh Tu Collection
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxheathfieldcps1
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptxmansk2
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Celine George
 

Recently uploaded (20)

[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdf
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17
 
Word Stress rules esl .pptx
Word Stress rules esl               .pptxWord Stress rules esl               .pptx
Word Stress rules esl .pptx
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf
 
How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdfPost Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptx
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in 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]<<"]"; } }