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
Starting Out with C++ from Control Structures to Objects (9th Edition)
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)
- I need help updating function makeMove to do the following in C Programming - Return type void - Parameter list includes i. Pointer to struct Player (i.e. player) ii. 2-d character array (i.e. board), size 8 rows and 8 cols (i.e. use macros ROW and COL) - Update the printf statements to use the struct field playerName- If data validation of length of user input is true (i.e. correct length) set local variable valid equal to function call isValid, pass as arguments i. Array moveii. Array board- Evaluate the value of validi. if false, display to the user their move is invalid ii. if true, display to the user their move is valid This code needs to be updated using the above instructions: void makeMove(char playerName[NAME], int playerNum, char board[ROW][COL]){ char move[THREE]; int valid = FALSE; // loop until the player enters a valid move while(valid == FALSE) { printf("%s, enter your move location (e.g. B6)\n", playerName); scanf("%s", move);…arrow_forwardWrite a C function that will take an array of integers as an argument and return the median value of the array. Note - The given array will not be sorted, hence first you need to sort the given array.And calculate the median for both odd and even length arrays.arrow_forwardWhat is wrong with the following C++ function? void Maximum(int a, int b, int& max) { if (a > b) max = a; else max = b; return max; }arrow_forward
- What will be the output of the following Python function? A. 4 B. 3 C. error D. 6arrow_forwardGiven the code segment below, what should be the data type of a in the function prototype of func(), given the call from main()? Do NOT use array indexing notation. If it is an invalid access, write INVALID (in all capital letters) as your answer. void func( ______ a);int main(){ double aData[15];func(*aData + 15);return 0;}arrow_forwardQuestion 1 This question deals with multiplying a 2 X 3 matrix by a 3 X 2 matrix. Your job is to input matrix A, followed by matrix B, then produce matrix C which is the product of A and B. At run time, please use the following for matrix A 1 2 3 4 5 6 followed by the following data for matrix B: 6 5 4 3 2 1 Your program should input the values for A and B in function main, then call a function matrix_mult to produce matrix C which consists of the product of A and B. Please use the following for naming your variables: Ar1c1, Ar1c2, Ar1c3. ..., where Ar1c1 refers to row 1, column 1 of matrix A, etc. (There will be a lot of variables). Do not use arrays to solve this problem.arrow_forward
- 1) What is the purpose of the code below? 2) What is each function used for in the code? 3) What are the names of the parameters/ arguments and what are they responsible for? 4) Why did you use a while loop in you code? 5) How did you accomplish the sort() to sort numbers? Code: #predefined modulesimport randomimport math #function to sort the list in ascending orderdef sort(x): #predefined function sort() x.sort() #print the sorted list print("\nSorted list is: ",str(x)) #function to find the sum of list elementsdef sum_of_list(x): #predefined function sum() Sum=sum(x) #return the sum of list elements return Sum #function to list the maximum from the listdef list_max(x): #predefined function max() maximum=max(x) #return maximum return maximum #function to test the above three functiondef main(): #set a flag variable flag=True #create a list list1=list() #initialize the list element by using randrange() predefined function of…arrow_forwardI need help with the following question. Also a visual representation using a Compiler to illustrate this would also be helpful Given the code segment below, what should be the data type of a in the function prototype of func(), given the call from main()? Do NOT use array indexing notation. If it is an invalid access, write INVALID (in all capital letters) as your answer. void func( ______ a); int main() { double aData[15]; func(aData[4]); return 0; }arrow_forwardc++ the following function header is for a function thattakes two pointers to double-precision, floatingpoint numbers x and y as parameters and does notreturn a value.void exchange( double *x, double y ) Select one: True Falsearrow_forward
- Please send me answer within 10 min!! I will rate you good for sure!! Please provide screenshot of code and output with explaination!! Write a C program that implements and tests a function that simulates strcmp function. You should not use functions from <string.h> library. You may use array and/or pointer notation to define the functions. More precisely, you should implement this function: Hint: int myStrcmp (const char *s1, const char *s2) This function compares the string pointed to by s1 to the string pointed to by s2. If the string pointed to by s1 comes before the string pointed to by s2 in dictionary ordering, then -1 is returned. If the string pointed to by s1 is the same as the string pointed to by s2, then 0 is returned (the compare function is case sensitive). Otherwise, 1 is returned. C programarrow_forward36- Consider the following function call: min(x, y) What is the function name and what is the first argument? a. The function name is min and the first argument is x b. Functions in Python don't have names (they're anonymous functions), but the first argument is x. c. The function name is min, but you need to see the function definition to determine the arguments. d. Functions in Python don't have names (they're anonymous functions) and you need to see the function definition to determine the argumentsarrow_forwardThe language we are using here is in Racket. Please enter the following code: (cond ((equal? 16 3) (+ 3 8)) ((equal? 16 8) 12) (else (* 6 3))) Write the return value for the above code. If replacing all of the 16's in the above code with 8, what is the return value? What about replacing the 16’s with 3? What does the cond function do?arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning