2: show Ihat hinatever n>3, Fn7a Where a = (1+5)/2 Lvia rec ssion)
Q: Consider this code: string name = "Mary Smith"; for (unsigned int i = 0; i < name.length(); i++) if…
A: #include<iostream>using namespace std;//driver programint main(){ string name = "Mary…
Q: gery lines can NOT be edited. New JAVA code vmust go inbetween.
A: Import the Scanner class.Create a Scanner object named scnr to read user input.Declare integer…
Q: Examine the code below: t = (1,) Rewrite the line of code to unpack the tuple.
A: Packing and unpacking a tuple: There is a very powerful tuple assignment function in Python that…
Q: Q3 Let L = {bab, ab, ???}. If |L²| = 8, what is a possible value of the unknown third element of L?…
A: Introduction: In computer science, a language L refers to a set of strings or sequences of symbols…
Q: What does the code below do? clear vec = randi(20,1,100)-10; iter=0; k=1; while k<= length(vec)…
A: The code clearvec = randi(20,1,100)-10;iter=0;k=1;while k<= length(vec) if vec(k)<0…
Q: thank you
A: The correct answer to this question is C. int num:scores /maxScore = num Explanation: - Inside the…
Q: Create the following variables • a = 2.3; b = -87.3; • A = [1,2; 4,5]; Create a matrix 2 × 2 B using…
A: #include<iostream>#include<stdlib.h>using namespace std;int printRandoms(int lower, int…
Q: Using the code posted below add code so it can plays multiple rounds of hangman using simple codes.…
A: This code has small issues for printing the round number. I have edited the code and attached the…
Q: %matplotlib inlineimport numpy as npfrom matplotlib import pyplot as pltimport math…
A: Approach to solving the question: Function Value Detailed explanation: Examples: Key references:…
Q: int main () int small[1 (5, 10, 15, 20, 25); int large[] - (50, 40, 30, 20, 10); vectorcint> v(10);…
A: Note: Answering the first question as per the guidelines. 6. Here, we have given the vector code to…
Q: Write a loop that subtracts 1 from each element in lowerScores. If the element was already 0 or…
A: Iterate over the given array If element is less than or equal to 0, we make it as 0 Else we decrease…
Q: Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma…
A: Here is the C code that uses a for loop to print all NUM_VALThe code's output ends with the last…
Q: Find the first 10 numbers greater than going.MAXAIVALUE UE that are idivisible by 56or 6.r 6.
A: Create a BigInteger instance maxLong and initialize it with the value of Long.MAX_VALUE. Print the…
Q: if v=[15,8,-6]; u=[3,-2,6]; then u.*v = 45-16-36 -45 16 -36 O45-16 36 None of the above if A=[3 1;4…
A: Here in this question we have given two questions.in first one we have to find dot of two vector.and…
Q: Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma…
A: Complete the given c program by writing a loop which will print the array elements using a comma and…
Q: Can you add an accumulator pattern on the sim_many_plays part. i need the help
A: Hello student Greetings Hope you are doing great. Thank you!!! In this version of the function,…
Q: Enter N For Nx2 Matrix: 3 homework3 [Java Application)…
A: Code import java.io.*;import java.util.*;class Main { static void rotate(int n, int matrix[][]){…
Q: How do I plot longitude vs F? longitude = -180; while longitude < 180 [XYZ,H,D,I,F] =…
A: To plot longitude vs. F using the provided code, you can follow these steps in MATLAB:Initialize an…
Q: In main(), call WriteHeader(); Declare an array of 6 integers named numbers. Declare variables for…
A: The objective of the question is to create a program that will ask the user to input 6 integers,…
Q: Suppose you are given an array of integers. You want to insert a number x to the array and rearrange…
A: Basically, an input array is taken and an element has to be inserted into it, in such a way that all…
Q: I need help completing this code where it says TODO // TODO set loginDateTime // TODO Lab 3 - set…
A: C++ is a popular programming language. C++ which refers to the one it is a cross-platform language…
Q: 14 What is the output of the following codes int arr[10] = {2,7,5,2,7,9,4,5,2,3}; int count[10] =…
A: In this question we have been given a program and we need to determine the output of the given…
Q: Given the integer array hourlySalaries with the size of NUM_INPUTS, write a for loop that sets…
A: Step-1: StartStep-2: Declare a final variable NUM_INPUTS and initialize with 5Step-3: Declare an…
Q: Considr The follo wng rodr [a,7,5] aList for val ニ aLIst: in val- va1-2 pint CaList) %3D whar is nn?…
A: Python: alist = [9, 7, 5] for val in alist: val = val - 2 print(alist)
Q: x = zeros(5,5) for i = 1:1:5 for j = 1:1:5 x(i,j) = i*j; end end Which of the following best…
A: 1) We have below code is question x = zeros(5,5)for i = 1:1:5 for j = 1:1:5 x(i,j) = i*j;…
Q: I think the argument should be ((q-->p) AND p) -->q --please advise
A: - We have to work on the statements and correct it.


Step by step
Solved in 2 steps

- Hi in the below code I would like to remove the blank tokens and how to achieve it. #include <stdio.h> #include <string.h> #include <stdlib.h> int count_tokens(const char* str) { int count = 0; int invalidToken = 0; // set false for(int i = 0; i <= strlen(str); i++) { if( i == strlen(str) || str[i] == 32){ // if past end of string, or if space if(invalidToken) { invalidToken = 0; // set false continue; } else { count++; // increment count only if token was not invalid continue; } } if( !(str[i] >= 97 && str[i] <= 122) ) { // if not lowercase letter invalidToken = 1; // set true } } return count; } char** split_tokens(const char* str) { char **tokenArr; tokenArr = (char **) malloc(count_tokens(str) * sizeof(char*)); /*use count_tokes() to determine the length*/ int…Can someone help me answer this question?#include <iostream>using namespace std; char* duplicateWithoutBlanks(char *word){int len = sizeof(word); char *new_str = new char[len + 1]; int k = 0; for (int i = 0; i < len; ++i){if (word[i] != ' ')new_str[k++] = word[i];} new_str[k] = '\0'; return new_str;} int main(){// Testing code char word[] = "Hello, World!"; char* result = duplicateWithoutBlanks(word); cout<< "word: "<< word<< "\nResult: "<< result; ; return 0;} What to change to out put the same word without blank?
- Lab 0(L): I Can, Therefore I MustJUnit: P2J12Test.javaA jovial old grandpa mathematician straight out of central casting often appearing in Numberphilevideos, Neil Sloane is behind the Online Encyclopedia of Integer Sequences, a wonderful tool forcombinatorial explorations. This lab has you implement two methods to generate elements of twointeresting integer sequences whose chaotic behaviour emerges from iteration of a deceptivelysimple rule. Both sequences are filled in ascending order in a greedy fashion, so that each elementis always the smallest number that avoids creating a conflict with the previously generatedelements in the sequence.Note that being defined by mathematicians, these sequences start from the position one instead ofthe position zero, the way how sequences work for us budding computer scientists who have toactually get our hands dirty and therefore prefer zero-based indexing. When asked to produce thefirst n elements of the sequence, these methods should create an…2184=9100(.03*t)Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, then backwards. End each loop with a newline. Ex: If courseGrades = {7, 9, 11, 10}, print:7 9 11 10 10 11 9 7 Hint: Use two for loops. Second loop starts with i = NUM_VALS - 1. Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element array (int courseGrades[4]). Also note: If the submitted code tries to access an invalid array element, such as courseGrades[9] for a 4-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message. #include <iostream>using namespace std; int main() { const int NUM_VALS = 4; int courseGrades[NUM_VALS]; int i; for (i = 0; i < NUM_VALS; ++i) { cin >> courseGrades[i]; } /* Your solution goes…
- Can you fix this please? with 5 53 5099 1223 567 17 4 1871 8069 3581 6841 #include <iostream>using namespace std; const int SORT_MAX_SIZE = 8; bool IsPrimeRecur(int dividend, int divisor) { if (divisor == 1) { return true; } if (dividend % divisor == 0) { return false; } return IsPrimeRecur(dividend, divisor-1);} bool IsArrayPrimeRecur(int arr[], int size, int index) { cout << "Entering IsArrayPrimeRecur" << endl; if (index == size) { cout << "Leaving IsArrayPrimeRecur" << endl; return true; } if (!IsPrimeRecur(arr[index], arr[index]-1)) { cout << "Leaving IsArrayPrimeRecur" << endl; return false; } return IsArrayPrimeRecur(arr, size, index+1);} bool IsArrayPrimeIter(int arr[], int size) { cout << "Entering IsArrayPrimeIter" << endl; for (int i = 0; i < size; i++) { for (int j = 2; j < arr[i]; j++) { if (arr[i] % j == 0) {…Please don’t use chegg C++ programming You are playing a mobile game with circular balls. At the beginning, you are given an string representing an array of integers where every element represents radius of the circle. At every stage, you need to pick the two largest circles and merge them together according to following set of rules: 1)If r1 == r2, both circles are vanished 2) If r1 != r2, find abs(r1 - r2) as new radius and replace it higher radius circle and then remove the other circle. At the end of the game, there will be at most one circle left. If there are no circle left, return 0. Otherwise return the radius of the last circle. You MUST use a Priority Queue implementation to receive credit. You may NOT use STL to implement the Priority Queue directly, however you are allowed to use vectors and such. Case 1:Input 1: 3 3 Output 1: 0 Case 2:Input 2: 1 2 3 1 Output 2: 1 Case 3:Input 3: 30 80 50 10 90 20 50Output 3: 10text file 80 1 2 3 100 100 100 1001 0 2 100 3 4 100 1002 2 0 4 4 100 5 1003 100 4 0 100 100 4 100100 3 4 100 0 3 3 3100 4 100 100 3 0 100 1100 100 5 4 3 100 0 2100 100 100 100 3 1 2 0 My code below. I am getting an error when trying to create my adjacency matrix. i dont know what i am doing wrong def readMatrix(inputfilename): ''' Returns a two-dimentional array created from the data in the given file. Pre: 'inputfilename' is the name of a text file whose first row contains the number of vertices in a graph and whose subsequent rows contain the rows of the adjacency matrix of the graph. ''' # Open the file f = open(inputfilename, 'r') # Read the number of vertices from the first line of the file n = int(f.readline().strip()) # Read the rest of the file stripping off the newline characters and splitting it into # a list of intger values rest = f.read().strip().split() # Create the adjacency matrix adjMat = []…
- JAVA PROGRAM PLEASE MODIFY THIS PROGRAM SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL TEST CASES. BECAUSE IT DOES NOT PASS ALL THE TEXT CASES. IT ONLY PASSES 8 PUT OF 16 TEXT CASES. ALL LENGHTS, HEIGHS AND ARRAY ELEMENTS ARE IN THREE DIGITS AFTER THE DEICIMAL POINT. ALSO, WHEN YOU TYPE BADFILE.TXT IT SHOULD SAY AFER THAT Please enter the file name AGAIN or type QUIT to exit:\n THEN YOU TYPE IN THE FILE NAME. I PROVIDED SCREENSHOTS OF THE FAILED TEST CASES.AND THE INPUTS. import java.io.*;import java.util.*;public class ArrayListOperations { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while(true) { System.out.print("Please enter the file name or type QUIT to exit:\n"); String filename = scanner.nextLine(); if(filename.equalsIgnoreCase("QUIT")) { break; } File file = new File(filename); if(!file.exists()) {…Question 16 Rk Full explain this question very fast solution sent meQuestion 1: Magic Matrix Magic square is an ? × ? matrix that is filled with the numbers 1,2,3, . . . . . , ?2 is a magic square if the sum of the elements in each row, in each column, and in the two diagonals is the same value. 6 1 8 7 5 3 2 9 4 Write a Java code to randomly generate a 3X3 matrix and check if the matrix is the magic square. In your code you must test two features: a. Does each of the numbers 1,2,3,….9 occur in the matrix? b. Are the sums of the rows, columns, and diagonals equal to each other? Note: to generate a random number use the method Math.random() which generates a pseudo random number greater than or equal to 0 and less than 1. Sample Output could be as follows: Sample 1: The randomly generated matrix is: 4 3 8 9 5 1 2 7 6 Sample 2: The randomly generated matrix is: 4 9 2 3 5 7 8 1 6











