2] What is the output of the following code? plic class Test { ublic static void main(String[] args) { int[][] matrix = {{1, 2, 3, 4), {4, 5, 6, 7}, {8, 9, 10, 11}, (12, 13, 14, 15}}; for (int i = 0; i < 4; i++) System.out.print (matrix[i][1] + " "); }
Q: #include using namespace std; int BinSearch(int arr[],int beg, int end, int key){ if(beg >…
A: Program after removing function #include<iostream>#include<stdlib.h>using namespace…
Q: edit code to print letters not numbers #include void main(){ //Required matrices and…
A: Soluton: Given code: #include<stdio.h> void main(){ //Required matrices and variables…
Q: # includeusing namespace std; int main (){int m[7]= {10, 1, 1, 111, 1, 13};int i ;coutusing…
A: We can initialise array and fix the elements or elements can be inserted by user at execution In…
Q: #include using namespace std; #define numVl 3 struct thNde { thNde* parent; int…
A: The code is written in C++ but instead of cout used printf for printing the outputs in code. Some…
Q: Question 1 Blank 1 Blank 2 Blank 3 What will be printed after executing the following C++ code? int…
A: Here, the content of array tt is subtracted from array dd, and stored in array rst. The order is…
Q: Write a small matrix library The library should have the following functions: double…
A: here in the question ask for a code for given functionality . i have provided my logic in c++…
Q: #include #include using namespace std; void PrintSize(vector numsList) { cout intList (3);…
A: Include the necessary header files for input/output and vectors. Define a function "PrintSize" that…
Q: Project Description: In this project you implement an ArrayStack ADT and use the stack for…
A: Here is the complete code of the problem.See below steps
Q: Code: #include using namespace std; void BUBBLE(int A[],int N){ for(int k=0;kA[ptr+1]){…
A: Explanation: To remove the function from the program and writing everything into a main function is…
Q: This part requires that you implement a C function that takes in as parameters two arrays and their…
A: #include <stdio.h>//method to find and print longest common sequencevoid…
Q: #include using namespace std; template class MyArray { private: BT *array; int size; int…
A: Step 1: Declare class SomeObj with member id. Step 2: Define default constructor that initializes id…
Q: Problem Description Gary being the smartest guy in the town is a friend of you. He challenges you…
A: String In their most basic forms, there are two different sorts of string datatypes: fixed-length…
Q: The main method in C which calls all the above functions is: #include int main(){ int s1[100],…
A: Code: #include <stdio.h>#include <stdlib.h>typedef struct node *nodeptr;typedef struct…
Q: how to tweak the code so that when i enter for computer's ship it only shows whether i missed or hit…
A: So to do this you just have to remove the display_board() method from line no. 94 and line no.100…
Q: b[2] A. int В. ВОХ x.n a[2].a C. pointer to pointer to char p.n D. char x.args[3] E. int pointer v…
A: The question is on match the correct option.
Q: Programming c
A: Array is arranging or collection of elements of same datatype or homogeneous datatype. Explanation…
Q: Run the Debugger on the program several time. Trace the execution of the the function oubble sort.…
A: Import necessary packages to get the standard input-output. Define two functions as print_array and…
Q: #include using namespace std; const int ROWS = 10; const int COLS = 10; int…
A: To swap the elements of odd rows between arrays A and B, you can modify the swap function as…
Q: In this lab, you use what you have learned about searching an array to find an exact match to…
A: #include <iostream>#include <string>using namespace std; int main() { string…
Q: int a[ 10] = {1,5,3,8,4,2,6,9,7}; int *p; p = &a[2]; p[0] = 10; p[1] = 15; What are the values of a?
A: Required:
Q: What is the value of the variable ss after the following code is executed? int x[ 7 ] =…
A: In the given program, an array of size 7 is defined which contains 6 elements. Then, a variable ss…
Q: Fix the errors and find the lowest marks entered by the user struct std{ string name; int reg_no;…
A: Given data is shown below: Fix the errors and find the lowest marks entered by the user struct…
Q: A/ find code optimization method to this code and then find type to this code 1-…
A: Here is the optimised code:
Q: using namespace std; int main() [double degree [6] [2] =(30,40,10,70, 20, 30, 60, 70, 30, 10, 10,…
A: Answer: 60 Correct option is : 4
Q: #include int arrC[10] = {0}; int bSearch(int arr[], int l, int h, int key);
A:
Q: #include using namespace std; class Student public: void setMarks(){ } double getAV(double a[]){…
A: The output will be 40 (option 2) Explanation:- Output In this program, the array are initialized…
Q: int X[10]={2,0,6,11,4,5,9,11,-2,-1); %3D From the code above, what is the value of X[8] ?
A: Code: #include <iostream>using namespace std; int main(){ //as index value starts from 0…
Q: #include using namespace std; const int ROWS = 10; const int COLS = 10; int…
A: Algorithm:Declare two 10x10 two-dimensional arrays A and B of type integerInitialize constants MIN…
Q: This C++ program keeps giving me the wrong median. #include using namespace std; double…
A: Thе program usеs thе following algorithm to calculatе thе mеdian of an array:Sort thе array in…
Q: #include #include #include #include using namespace std::chrono; using namespace std; void…
A: Start by including the necessary header files for input/output operations (<iostream>), random…
Q: // MichiganCities.cpp - This program prints a message for invalid cities in Michigan. // Input:…
A: You need to check with each and every element in the array of strings and if it equals the input…
Q: Q1 #include int arrC[10] = {0}; int bSearch(int arr[], int l, int h, int key);…
A: The Flowchart for the algorithm: Handwritten on image.
Q: matrix = {{1,2},{4,5}} this in c++
A: Required:
Q: #include #include int MAX_SIZE = 10; int n = 0; //A counter variable which will keep track of…
A: Task : In the given C code, the output of the code is not correct. The task is to debug the code…
Q: #include #include int MAX_SIZE = 10; int n = 0; //A counter variable which will keep track of…
A: the program is given below:-
Q: Organize the code and write comments on each part of the program.
A: Answer is explained below
Q: #include using namespace std; int main() (double degree [6] [2] =(30,40, 10, 70, 20, 30, 60, 70,…
A: C++ Program: #include <iostream>using namespace std; int main(){ double…
Q: #include using namespace std; double median(int *, int); int get_mode(int *, int); int…
A: Prompt for Numbеr of Studеnts:Thе program prompts thе usеr to еntеr thе numbеr of studеnts…
Q: #include #include #include #include using namespace std::chrono; using namespace std; void…
A: Below I am attaching a code for all file: 1 VectorAdd.cpp 2 ParallelVectorAdd.cpp
Q: Matrix.h #include #include using namespace std; #ifndef MATRIX_H #define MATRIX_H class Matrix {…
A: 1. Create a header file `Matrix.h` that defines the `Matrix` class with private member variables…
Q: has_perfect You are to write a function has "perfect(graph)" that takes in a BIPARTITE graph as its…
A: The given below program is in python using the graph data structure.
Q: Don't delete the code. Fix the error and make sure it runs. #include using namespace std; class…
A: The code is written in C++.
Q: What values are stored in the list numList? numberList ()
A: Answer the above question are as follows
Q: //Before calculating the median, we must sort the 1/array. //1f the array is even... if…
A: The given problem is related to C++, where the partially compelete code is given and the requirement…
Q: #include int arrC[10] = {0}; int bSearch(int arr[], int l, int h, int key); int…
A: Flowchart of above program:
Step by step
Solved in 2 steps with 2 images
- #include <stdio.h>#include <stdlib.h> int MAX_SIZE = 10;int n = 0; //A counter variable which will keep track of number of elements in arr. void append(int *arr, int element){ if(n == MAX_SIZE) { MAX_SIZE = MAX_SIZE * 2; int *ptr = (int*)malloc(MAX_SIZE * sizeof(int)); //Copy elements of existing array to a new array for(int i=0;i<n;i++) { ptr[i] = arr[i]; } arr = ptr; n++; } arr[n] = element;} int get(int *arr, int index){ return arr[index];}int main(){ int *arr = (int*)malloc(MAX_SIZE * sizeof(int)); n = 10; for(int i=0;i<n;i++) arr[i] = i+1; printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n); printf("\nArray: "); for(int i=0;i<n;i++) printf("%d ", arr[i]); printf("\n\nAdding an element"); append(arr, 11); printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n);…#include <iostream>//#include <vector> using namespace std; class Vec {public:Vec() {sz = 0;cap = 1;p_arr = new int[cap];} int size(){return this->sz;}int capacity(){return this->cap;}void reserve( int n ){// TODO:// (0) check the n should be > size, otherwise// ignore this action.if ( n > sz ){// (1) create a new int array which size is n// and get its address//cout << "Adress:"<< &n << endl;int *newarr = new int [n];//cout << "Address: " << newarr << endl; // location // (2) use for loop to copy the old array to the// new arrayfor(int i = 0; i < sz; i++){newarr[i] = p_arr[i];}// (3) update the variable to the new addressthis->cap=n; // (4) delete old arraydelete[] newarr;}}void push_back( int v ){// TODO:if ( sz == cap ){ cap *= 2; reserve(cap);}p_arr[sz++] = v;// complete others}int at(int idx){return this->p_arr[idx];}private://vector<int> arr;int *p_arr;int sz = 0;int cap = 0; }; int main(){Vec v;…#include <iostream>#include <vector>using namespace std; void PrintVectors(vector<int> numsList) { unsigned int i; for (i = 0; i < numsList.size(); ++i) { cout << numsList.at(i) << " "; } cout << endl;} int main() { vector<int> numsList; int userInput; int i; for (i = 0; i < 3; ++i) { cin >> userInput; numsList.push_back(userInput); } numsList.erase(numsList.begin()+1); numsList.insert(numsList.begin()+1, 102); numsList.insert(numsList.begin()+1, 100); PrintVectors(numsList); return 0;} Not all tests passed clearTesting with inputs: 33 200 10 Output differs. See highlights below. Special character legend Your output 33 100 102 10 Expected output 100 33 102 10 clearTesting with inputs: 6 7 8 Output differs. See highlights below. Special character legend Your output 6 100 102 8 Expected output 100 6 102 8 Not sure what I did wrong but the the 33…
- #include <stdio.h> #include <string.h> int IsPasswordOkay(char* pass) { char Password[12]; strcpy(Password, pass); if (!strcmp(Password, "goodpass")) return(1); else return(0); } int main(int argc, char **argv) { int PwStatus; if (argc < 2) { printf("Input your password\n"); return(-1); } PwStatus = IsPasswordOkay(argv[1]); if (PwStatus == 0) { printf("Acces denied"); return(-1); } else { printf("Access granted"); return(1); } } Write a function to conduct input validation to secure the smallest buffer. You may call this function void SecurePasswordBuffer(const char *arg).#include <stdio.h>#include <stdlib.h> int MAX_SIZE = 10;int n = 0; //A counter variable which will keep track of number of elements in arr. void append(int *arr, int element){ if(n == MAX_SIZE) { MAX_SIZE = MAX_SIZE * 2; int *ptr = (int*)malloc(MAX_SIZE * sizeof(int)); //Copy elements of existing array to a new array for(int i=0;i<n;i++) { ptr[i] = arr[i]; } arr = ptr; n++; } arr[n] = element;} int get(int *arr, int index){ return arr[index];}int main(){ int *arr = (int*)malloc(MAX_SIZE * sizeof(int)); n = 10; for(int i=0;i<n;i++) arr[i] = i+1; printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n); printf("\nArray: "); for(int i=0;i<n;i++) printf("%d ", arr[i]); printf("\n\nAdding an element"); append(arr, 11); printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n);…using System; class TicTacToe { staticint player = 1; staticint choice; staticvoid Print( char[] board); staticvoid Main(string[] args) { Console.WriteLine(); Console.WriteLine($" {board[0]} | {board[1]} | {board[2]} "); Console.WriteLine($" {board[3]} | {board[4]} | {board[5]} "); Console.WriteLine($" {board[6]} | {board[7]} | {board[8]} "); Console.WriteLine(); } staticvoid Main(string[] args) { char[] board = newchar[9]; for (int i = 0; i < 9; i = i + 1) { board[i] = ' '; if( board[i]== 'O') Console.Write("It is your turn to place an X"); } Print(board); board[4] = 'X'; Print(board); board[0] = 'O'; Print(board); board[3] = 'X'; Print(board); board[5] = 'O'; Print(board); board[6] = 'X'; Print(board); board[2] = 'O'; Print(board); } } Hello! I need help with getting my code to compile. It's written in C# and i'm a beginner. it's giving me two errors and i'm not sure how to fix them. Please don't copy paste an answer from google.
- #include<iostream>using namespace std;const int rows=10;const int columns=10;int computer_board1[rows][columns];int computer_board2[rows][columns];int player_board[rows][columns];int x,y;void setboard(){for(int i=0;i<rows;i++){for(int j=0;j<columns;j++){computer_board1[i][j]=0;player_board[i][j]=0;}}}void display_computer_board1(){cout<<"Computer's Board"<<endl;cout<<" 0 1 2 3 4 5 6 7 8 9 "<<endl;for(int i=0;i<rows;i++){for(int j=0;j<columns;j++){if(j==0){cout<<i<<" ";}cout<<computer_board1[i][j]<<" "; }cout<<endl;}cout<<endl;}void display_player_board(){cout<<"Your Board"<<endl;cout<<" 0 1 2 3 4 5 6 7 8 9 "<<endl;for(int i=0;i<rows;i++){for(int j=0;j<columns;j++){if(j==0){cout<<i<<" ";}cout<<player_board[i][j]<<" "; } cout<<endl;} }void place_player_ships(){for(int i=1;i<=15;i++){cout<<"Horizontal…#include <iostream>#include <cstdlib>#include <time.h>#include <chrono> using namespace std::chrono;using namespace std; void randomVector(int vector[], int size){ for (int i = 0; i < size; i++) { //ToDo: Add Comment vector[i] = rand() % 100; }} int main(){ unsigned long size = 100000000; srand(time(0)); int *v1, *v2, *v3; //ToDo: Add Comment auto start = high_resolution_clock::now(); //ToDo: Add Comment v1 = (int *) malloc(size * sizeof(int *)); v2 = (int *) malloc(size * sizeof(int *)); v3 = (int *) malloc(size * sizeof(int *)); randomVector(v1, size); randomVector(v2, size); //ToDo: Add Comment for (int i = 0; i < size; i++) { v3[i] = v1[i] + v2[i]; } auto stop = high_resolution_clock::now(); //ToDo: Add Comment auto duration = duration_cast<microseconds>(stop - start); cout << "Time taken by function: " << duration.count()…helllp
- #include #include using namespace std; void PrintSize(vector numsList) { cout intList (3); PrintSize(intList); cin >> currval; while (currval >= 0) { } Type the program's output intList.push_back(currval); cin >> currVal; PrintSize(intList); intList.clear(); PrintSize(intList); return 0; 1 se mice with camScanner Check Next Input 1234-1 OutputQ: Convert this to sorted array #include<iostream> #include"Student.cpp" class StudentList { private: struct ListNode { Student astudent; ListNode *next; }; ListNode *head; public: StudentList(); ~StudentList(); int IsEmpty(); void Add(Student newstudent); void Remove(); void DisplayList(); }; StudentList::StudentList() { head=NULL; }; StudentList::~StudentList() { cout <<"\nDestructing the objects..\n"; while(IsEmpty()!=0) Remove(); if(IsEmpty()==0) cout <<"All students have been deleted from a list\n"; }; int StudentList::IsEmpty() { if(head==NULL) return 0; else return 1; }; void StudentList::Add(Student newstudent) { ListNode *newPtr=new ListNode; if(newPtr==NULL) cout <<"Cannot allocate memory"; else { newPtr->astudent=newstudent; newPtr->next=head; head=newPtr; } }; void StudentList::Remove() { if(IsEmpty()==0) cout <<"List empty on remove"; else { ListNode *temp=head;…#include<iostream>using namespace std;const int rows=10;const int columns=10;int computer_board1[rows][columns];int computer_board2[rows][columns];int player_board[rows][columns];int x,y;void setboard(){for(int i=0;i<rows;i++){for(int j=0;j<columns;j++){computer_board1[i][j]=0;player_board[i][j]=0;}}}void display_computer_board1(){cout<<"Computer's Board"<<endl;cout<<" 0 1 2 3 4 5 6 7 8 9 "<<endl;for(int i=0;i<rows;i++){for(int j=0;j<columns;j++){if(j==0){cout<<i<<" ";}cout<<computer_board1[i][j]<<" "; }cout<<endl;}cout<<endl;}void display_player_board(){cout<<"Your Board"<<endl;cout<<" 0 1 2 3 4 5 6 7 8 9 "<<endl;for(int i=0;i<rows;i++){for(int j=0;j<columns;j++){if(j==0){cout<<i<<" ";}cout<<player_board[i][j]<<" "; } cout<<endl;} }void place_player_ships(){for(int i=1;i<=15;i++){cout<<"Horizontal…