SlideShare una empresa de Scribd logo
1 de 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]<<"]";
}
}

Más contenido relacionado

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

Más de 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
 

Más de 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
 

Último

How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 

Último (20)

How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 

[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]<<"]"; } }