What is the output of the following
#include <iostream>
using namespace std;
// Function prototypes
void fil1Array(char [], int);
void showArray(const char [], int);
int main ()
{
const int SIZE = 8;
char prodCode[SIZE] = {‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’,};
fillArray(prodCode, SIZE);
showArray(prodCode, SIZE);
return 0;
}
// Definition of function fill Array.
// (Hint: 65 is the ASCII code for ‘A’)
void fillArray(char arr[], int size)
{
char code = 65;
for (int k = 0; k < size; code++, k++)
arr[k] = code;
}
// Definition of function showArray.
void showArray(const char codes[], int size)
{
for (int k = 0; k < size; k++)
cout ≪ codes[k];
cout ≪ endl;
}
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
EBK STARTING OUT WITH C++
Additional Engineering Textbook Solutions
Modern Database Management (12th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
Database Concepts (8th Edition)
Programming in C
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- Classwork Requirements: Developa program in C++ that: Reads as many test scores as the user wants from the keyboard (assuming at most 50scores). Test scores should be whole numbers. You must validate user input; only positive numbers are valid. Prints the scores in original order sorted from high to low the highest score the lowest score the average of the scores Implement the following functions using the given function prototypes: void displayArray(int array[], int size)- Displays the content of the array void selectionSort(int array[], int size)- sorts the array using the selection sort algorithm in descending Hint: refer to example 8-5 in the textbook. int findMax(int array[], int size)- finds and returns the highest element of the array int findMin(int array[], int size)- finds and returns the lowest element of the array double findAvg(int array[], int size)- finds and returns the average of the elements of the arrayarrow_forwardWrite C++ statement(s) to do the following: Declare an array alpha of 50 components of type int. Initialize each component of alpha to -1. Output the value of the first component of the array alpha. Set the value of the twenty-fifth component of the array alpha to 62. Set the value of the tenth component of alpha to three times the value of the fiftieth component of alpha plus 10. Use a for loop to output the value of a component of alpha if its index is a multiple of 2 or 3. Output the value of the last component of alpha. Output the value of the alpha so that 15 components per line are printed. Use a for loop to increment every other element (the even indexed elements). Use a for loop to create a new array, diffAlpha, whose elements are the differences between consecutive elements in alpha.arrow_forwardDescribe how to pass an array as a parameter to a function.arrow_forward
- FUNCTION AND ARRAY (C++ LANGUAGE) Create a sequence program that will input names to the arrayName array and then display the values in the array. Use a function for input values and display the values. (Create a program where you can input the full name and also create a program where you can input only the first name) -input 5 names only. - 2 functions - 2 codes upload code and outputarrow_forwardstate the statement either true or false.arrow_forwardNote: Write programs in c language format use in programs (Printf & Scanf)arrow_forward
- C++arrow_forwardGood Programming practices help in improving programs readability and understandability both for a programmer and for a general user. What changes would you make in the following program, written by a beginner, keeping in view the good programming practices.You are also required to write the output of the program if a user wants to find factorial of number 6.Note: The Program finds/calculates factorial of a number using a userdefined recursive function.#include<iostream> using namespace std;int f(int n);int main() {int n;cout << "Enter: "; cin >> n;cout << "Answer = " <<factorial(n);return 0;}int f(int n) {if(n > 1)return n * f(n - 1);else return 1; }arrow_forwardIn C++ float a[10] = {0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9}; float *b = &a[2]; Write an expression that uses b to copy the 6th element of the array to the 3rd element. DO NOT use a in your answer.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education