a. for (int i = 0; true; i++) System.out.println (a[i]); b. for (int i = 0; true; i++) ; System.out.println (a[i]): c. for (int i = 0; i <= a.length; i++) System.out.println (a[i]); 1) Which loop statement outputs the elements of array 'a'? 2/7 d. for (int i = 1; i <= a.length ; System.out.println (a[i-1]); e. None of the above
Q: int nums[] = {7,2,5,6,7,2,3,4,6}; int target = 12; int loc = 0; int iterations = 0; boolean found =…
A: Value of loc = 9 when print the value of loc
Q: #include using namespace std; class Box { Public: int length, width, sum, sub, div; Box…
A: The given program is written in the c++ programming language. It can be executed in any one of the…
Q: #include int main() { int a[5][5],i,j; printf("enter elements into 5 * 5 matrix");…
A: Introduction of Flow Chart: The flow chart represents the pictorial representation of any program.…
Q: #include int main() { int arr[10]; int i; for (i=0; i<10; i++){ arr[i] =…
A: As given, we need add the following code parts to the given code - (1) Copy the content of the first…
Q: void showValues(int a[4]), int cols = 5) { for (int roW = 1; row <= 4; row++) for (int col = 1; col…
A: Task :- Identify the errors in given piece of code.
Q: #include #include using namespace std; //hasHelpOption() definition int hasHelpOption(int argc,…
A: Your program gives the following warning on compilation: It is because the compiler can not tell…
Q: * Convert binary to octal using recursion. If invali returns null. Must use * recursion. **/ public…
A: The answer is given below.
Q: 5. Given the following code AFIFOQueue aQue = new AFIFOQueue (10); AStack astack - new AStack (10);…
A: Push inserts the element at the top of the stack and Pop removes the top element from Stack Enqueue…
Q: sum = 0; for (int i = 1; i<n; i = sum++ 2*i)
A: Algorithm for the given code Declare a variable n and take the input for the value n. Declare sum…
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: 1. Write a nested loop that displays 15 rows of '*' characters. There should be 30.'*' characters in…
A: As per the requirement program first program is developed. Note: As per our guidelines we are…
Q: #include • #include • main() { int d; d=CHAR_MIN; printf("%d",d); }
A: Output of the given code
Q: // Assume all libraries are included void QQ(int n); // int main () { // Random questions QQ (5) ; 3…
A: this program in c++ it bascially call function QQ(5); QQ ( int n ) this function checks if…
Q: #include #include using namespace std; int main() { int arr [7] = {9, 4, 1, 6, 2}; int i, j, k,…
A: Answer: A function is a block of code that runs when we call any function. You can pass data into…
Q: are some ways you can make code more efficient when using if-else blocks?
A: some ways you can make code more efficient when using if-else blocks
Q: Complete the code: string cars[5] = {"Volvo", "BMW", "Ford", "Mazda", "Honda"}; for(int i = 0; i< _;…
A: string cars[5]={"Volvo","BMW","Ford","Mazda","Honda"}; for(int i=0;i<5;i++){…
Q: Why does little-endian vs. big-endian matter here in this code
A: *In case of multiple questions, only the first will be answered. For other questions, put separate…
Q: using System; class Program { publicstaticvoid Main(string[] args) { int number = 1,i; while…
A: Required: how can this program be fixed to choose three random numbers in C# between 1-88…
Q: extern "C" int f(int *,int,int); int a[2][2] = {{11,12},{21,22}}; void setup() {…
A: This code is an example of an Arduino sketch written in C/C++ language, which makes use of assembly…
Q: #include struct dna { int number; char text; char stringvalue[30]; }; int main() {…
A: NOTE: - As asked the comments are being added on each line of the program. Any modification other…
Q: 3: The code on the right is supposed to be the ARM code for procA; however, there are problems with…
A: The code given: C code: int procA(int x, int y) { int perimeter = (x+y)* 2; return perimeter; }…
Q: function main() { # ist: input numbers #w: outer for loop index # X: inner for loop index # y:…
A: Filling blanks in given code function main() {# ist: input numbers #w: outer for loop index# X:…
Q: #include using namespace std; const int y = 1; int main () ( int static y - 2; int i = 3, j - 4, m…
A: The output along with the explanation is given below:
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: What is the ouput of the following C code segmer void * T( void* me) { int s=0; for (int k=1; k<=me;…
A: It is defined as a powerful general-purpose programming language. It can be used to develop software…
Q: mkfifo("mypipe"); if (!fork()) { fp popen("echo 37 > mypipe", "w"); status = pclose(fp); } else {…
A: First of all the program creates a pipe named mypipe. After that the fork() command is executed.…
Q: a) b) C) d) CO 1 123 2 4 5 6 7 8 9 10 11 12 20 19 TELE 345 13 #include #include int main(){ 14 15…
A:
Q: #include #include using namespace std; int index1(char *T,char *P) { int t=0,p=0,i,j,r;…
A: To remove function, use all statements outside the function and remove the function header. instead…
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: #include #include int MAX_SIZE = 10; int n = 0; //A counter variable which will keep track of…
A: The objective is to solve the given code using struct type.
Q: A/ find code optimization method to this code and then find type to this code 1-…
A: Here is the optimised code:
Q: What are the output from the C++ codes segments below? 1- {int x=10; while(x>5); { cout<<x<<"\n";…
A: The loop statements such as while and for loops run the block of code multiples times until the…
Q: 1、Counting Primitive Operations void STRAITMAXMIN(A,n,max,min) //Set the maximum value in A to max…
A: Given : { int i,n max=min=A[1] for i=2 to n { if A[i]> max…
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: int calculatepower (int x, int y){ if (y > 0) return x* else return 1; int main (){ int num, pwr;…
A: Ans is given in next steps
Q: The mechanics described in this exercise can be used to implement a game lights out. For basic…
A: // C++ Code For A Boolean Matrix Question#include <bits/stdc++.h> using namespace std;#define…
Q: The following definition has errors. Locate as many as you can. A) void showValues(int nums) {for…
A: A) void showValues(int nums) {for (int count = 0; count < 8; count++) cout << nums[count];}…
Q: 2.20 LAB: Hypotenuse Given two numbers that represent the lengths of a right triangle's legs (sides…
A: Introduction: The name "Hypotenuse" in mathematics derives from the Greek word hypoteinousa, which…
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: A CNC router has a tool which can be moved along three axes to carve shapes out of metal or wood…
A: Required C++ is mentioned below with output:
Q: Which aggregating operations on struct variables are permissible but not on array variables?
A: Introduction: The following table summarizes the aggregate operations that are permitted on…
Q: Data Structures the hasBalancedParentheses () method. Note: this can be done both iteratively or…
A: NOTE: Only function is provided as per the question, and not the complete code. c++ function code:…
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…
Step by step
Solved in 2 steps
- #include <iostream>#include <string.h>using namespace std;int index1(char *T,char *P){int t=0,p=0,i,j,r;t = strlen(T);p = strlen(P);i=0;int max = t - p + 1;while(i<max){for(j=0;j<p;j++){if(P[j]==T[i+j]){r = i;break;}else r = -1;}i++;}return r;} int main(){ int l;char c[100];char d[100];cout<<"Enter First String\n"; cin>>c;cout<<"Enter Second String\n";cin>>d;l = index1(c,d);cout<<l; return 0;} Note: Remove FuncationDebugEight4: Here is the code that needs to be debugged, I fixed some but it will not display the words in reverse at the end: // Application allows user to enter a series of words // and displays them in reverse order import java.util.*; public class DebugEight4 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int x = 0, y; String array[] = new String[100]; String entry; final String STOP = "XXX"; StringBuffer message = new StringBuffer("The words in reverse order are\n"); System.out.println("Enter any word\n" + "Enter + STOP + when you want to stop"); entry = input.next(); while(!(entry.equals(STOP))) { array[x] = entry; ++x; System.out.println("Enter another word\n" + "Enter " + STOP + " when you want to stop"); entry = input.next(); } for(y = x - 1; y > 0; ++y) {…C programming #include <stdio.h>int main() {int i, j, n ;printf("height? ") ;scanf("%2d", &n) ;for (i = 1 ; i <= n ; i++) {// printf("%d: ", i) ;for (j = 1 ; j <= i ; j++) {// Pick *one* of the following// printf("%d", j % 10) ;printf("*") ;}printf("\n") ;}return 0 ;} How can I get output like this by editing the given programming -- height? 5************************* and then how can I get the following?- height? 7 1 123 12345 1234567 123456789 12345678901 1234567890123
- (-465)10 + (325)10 = ?#include <stdio.h> struct Single { int num; }; void printSingle(int f) { int binaryNum[33]; int i = 0; while(f>0) { binaryNum[i] = f % 2; f = f/2; i++; } for (int j=i-1; j>= 0; j--) { printf("%d",binaryNum[j]); } } int main() { struct Single single; single.num = 33; printf("Number: %d\n",single.num); printSingle(single.num); return 0; }#include using namespace std; void some_action_1(int); int main() { cout<#include <stdio.h> struct Single { int num; }; void printSingle(int f) { int binaryNum[33]; int i = 0; while(f>0) { binaryNum[i] = f % 2; f = f/2; i++; } for (int j=i-1; j>= 0; j--) { printf("%d",binaryNum[j]); } } int main() { struct Single single; single.num = 33; printf("Number: %d\n",single.num); printSingle(single.num); return 0; }using System; class Program { publicstaticvoid Main(string[] args) { int number = 1; while (number <= 88) { Console.WriteLine(number); number = number + 2; } int[] randNo = newint[88]; Random r = new Random(); int i=0; while (number <= 88) { randNo[i] = number; number+=1; i+=1; } for (i = 0; i < 3; i++) { Console.WriteLine("Random Numbers between 1 and 88 are " + randNo[r.Next(1, 88)]); } } } this code counts from 1-88 in odds and then selects three different random numbers. it keeps choosing 0 as a random number everytime. how can that be fixed?using System; class main { publicstaticvoid Main(string[] args) { int number = 1; while (number <= 88) { int i; Random r = new Random(); int[] randNo=newint[3]; for(i=0;i<3;i++) { randNo[i]= r.Next(1,88); Console.WriteLine("Random Number between 1 and 88 is "+randNo[i]); } } } } This code is supposed to count from 1-88 and then select three random numbers from the list but instead it generates an infinite loop of random numers between 1-88. how can it be fixed?#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 <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 using namespace std; int main() (double degree [6] [2]= (30,40,10,70, 20, 30, 60, 70, 30, 10, 10, 85); int buffer=degree[0][0]; for (int i=1;ibuffer) buffer=degree[i][0]; cout<SEE MORE QUESTIONSRecommended textbooks for youDatabase 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:PEARSONC 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 EducationDatabase 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:PEARSONC 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