Write a program that will take the sum of the odd-indexed array elements in array of 50 integers completely filled. This is my C++ Codes but when I entered the 50 integers, the sum of the odd-indexed are wrong. Can you fix the errors? Please still use header files iostream header files. This is a topic under Data Structures: Arrays.
Q: Write a complete C code to print the mode of an array. The mode is defined as the element that is…
A: C program to find the mode of a array
Q: I need help in debugging this program. The original question is ->Write a function void…
A: void ConvertUpper(char S[], int n) { int i; for (i = 0; i < n; i++) { /* if the…
Q: Write a C++ function (call it index_max) that finds the maximum number in the array, that is passed…
A: We need to write a C++ code for the given scenario.
Q: I need a short program that takes in a string of characters such as: "-3 44 * 2 +" and puts the…
A: Code: #include <iostream>#include <vector>using namespace std;int main() { string n;…
Q: use c code to Write a function that gets an array as a parameter, sorts it in a descending fashion…
A: Note: The sample output given in the question contains the array values sorted in an ascending…
Q: includes a function to calculate the mode (most frequently occurring score) includes a function to…
A: Note: Since you have again posted multiple independent questions in the same request, we will solve…
Q: solve using c++. Let the user enter two arrays. Add(concatenation) the arrays into one extended…
A: The solution to the given problem is below.
Q: 3. Write a complete C program that inputs 10 integer numbers from user in an array, then it finds…
A: Answer is given in step2.
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: N real numbers entered by the user on the keyboard are in order from the smallest to the largest.…
A: C is indeed one of the most popular programming language of present time. It is one of the simplest…
Q: Write a C program that reads an unspecified number of integers from a file called nums.txt ( up to a…
A: C Program to read file with numbers, with 2 functions sum_of_divs and max_sum_and_pos, giving sum of…
Q: Q2: Write a C++ program, using function, to compute the number of zeros in the array,
A: code: //C++ program to count the number of zeros in a given array#include<iostream>using…
Q: Q1/ write a c++ program to find the value of array C from add array A and array B?use (five number)…
A: #include<iostream>using namespace std; int main(){ int size, i, A[10], B[10], C[10]; cout…
Q: Write a C++ program that will load 100 integers into array x. Separate the even from the odd valued…
A: The number of braces opened is not equal to the number of braces closed, close the braces. In the…
Q: Write a program using c++ that: includes a function that reads integers consisting of students’…
A: A required C++ program is as follows, #include<iostream> //header files for cin/cout…
Q: C PROGRAMMING - write a function get_output which takes a two dimensional array as parameter and…
A: #include <stdio.h> int get_output(int n, int arr[n][n]){ int count=0; for (int i = 0; i…
Q: What will be the output of the. -11 ?following C++ code #include #include using namespace std; int…
A: Hello student. Warm welcome from my side. Hope you are doing great. I will try my best to answer…
Q: Write a program to swap the values of 2 arrays using pointers. Create a function (void inputArray)…
A: Required:
Q: Write a C++ program that generate 20 random integers between 10 and 90 and then stores it in an…
A: Declare an array of size 20. Then assign 20 random number using loop and rand() % 90 + 10 Mean is…
Q: Show code to print the element of arr2 that corresponds to *p (from arr1) -- use no variables beyond…
A: #include <iostream>using namespace std;int main(){ const int MAX = 5; double arr1[MAX] =…
Q: a) Write the sequential version in C++ (refer the sequential algorithm below). Show the proof of…
A: Make a function sequential with parameters as: a : 2d matrix b: vector of size n c: vector of size m
Q: Q1/ write a c++ program to find the value of array C from add array A and array B?use (five number)…
A: In C++, an array is a variable that can store multiple values of the same type. C++ provides the…
Q: I have a question about programming in C(89) C. Could someone please show me how to make a program…
A: The ask is to write a C program to: - take user input for an array size - take user input for each…
Q: in this exercise, please do not include and use string class. The function is using only array…
A: Please refer below for your reference: According to company guidelines we are restricted to answer…
Q: Use the following array of 8 integers to answer the following questions, {7,3,7,7,7,5,2,7} a) You…
A: Algorithm: Start Initialize array with given data Initialize the variable NumbertoMove with 7 Using…
Q: In my C++ program, the function takes in an upper and lower bound. Then the user keeps entering…
A: In the given program, areNumbersInBound function receiving the parameters in the wrong order as the…
Q: write a program in c++ that prompts the used to enter 50 intergers and stores them in an array. the…
A: Program code: //include the required header files #include <iostream> #include…
Q: 3.use c code to Write a function that gets two same size arrays as parameters and determines if they…
A: PROGRAM EXPLANATION: - For arrays to be in permutation, they must contain the same elements in…
Q: Q1/I write a program in C ++ to read the values of the elements of a two-dimensional array (4x3) and…
A: The simplest type of a multidimensional array is a two-dimensional array. The simplest way to…
Q: PLEASE ANSWER THE QUESTION IN C! 1) Instead of reading several lines of text, just hard-code the…
A: //a) #include <stdio.h>#include <ctype.h>#include<conio.h>#include…
Q: Q1/ write a c++ program to find the value of array C from add array A and array B?use (five number)…
A: Note: We are authorized to answer one question at a time, since you have not mentioned which…
Q: Question: Using good OOP, write a C++ program that will compare two arrays to test for the same…
A: comFile1.txt 10 20 25 25 30 35 comFile2.txt 25 35 10 15 30 20 _____________________…
Q: Marry's teacher assigned her to fill the elements of an integer array of size 10 with 3 digit…
A: Write a C++ program in which Marry enters the 10 values filled by her in the array and the program…
Q: 3. Write a complete C program that inputs 10 integer numbers from user in an array, then it finds…
A: 1) Start 2) declare an array of size 10, max=0 to store maximum element and sum to store sum of…
Q: Write a definition for pointer variables that will be used to point to dynamic arrays? The array…
A: A pointer variable is similar to the other variables that may be used to store data. A pointer,…
Q: Q1/ write a c++ program to find the value of array C from add array A and array B?use (five number)…
A: #include<iostream> using namespace std; int main() // main function { int…
Q: Q1/ write a c++ program to find the value of array C from add array A and array B?use (five number)…
A: #include <iostream> using namespace std; int main(){ //create three arrays int…
Q: 7-) Write a program that finds the roots of the equation ax?+bx+c=0. The requirements for this…
A: #include <math.h>#include <stdio.h>int main() { double a, b, c, discriminant, root1,…
Q: How can I find the Pseudocodes and C++ codes for this problem?
A: INITIALIZE the array with 50 elements. FOR i=0 to i<50 IF i%2!=0…
Q: Q3. Write a python code to do the following operations. 1. Create a stress tensor and a strain…
A: I have provided the answer based on Python Programming. Detailed comments are included for a better…
Q: 1-Write a C++ program to a) define 1-D array of length 100. b) Fill the array with integers numbers…
A: The problem is based on the basics of arrays in c++ programming language.
Q: Write a C program that reads an unspecified number of integers from a file called nums.txt ( up to a…
A: Declare the given functions as follows. void max_sum_and_po(int[] a);int sum_of_divs(int n);…
Q: Write a program that would initialize two 2D-Arrays (matrix A and matrix B) using numbers n the…
A: code #include <iostream> using namespace std; int main(){int…
Q: The table below shows the deformed lengths of four (4) springs of length 10 cm each when stretched…
A: Algorithm: Start Initialize maxLength array with given data Declare another array spring of length…
Q: Write a C++ program that will load 100 integers into array x. Separate the even from the odd valued…
A: Program code: //header files #include <iostream> using namespace std; //declaration of…
Q: Choo se the best C++ code segment that: 1. Counts the number of space character ('') in the array.…
A: The program require us to do two things: Count number of space characters At even index replace…
Q: Q4: Write C++ program using funcions, write saperate functions for input and output, program should…
A: Code: #include <iostream> using namespace std; int func(int n[],int size)//function printing…
Q: 11. Given an array of integer datatype below, write a C++ program to print all positive 3-digit…
A: Program to print all positive 3 digit number in a given array
Q: Write a function definition for a function named getPrev which does the following: 1) Accepts the…
A: Answer in step2 Write a function definition for a function named getPrev which does the following:…
Problem:
Write a
This is my C++ Codes but when I entered the 50 integers, the sum of the odd-indexed are wrong. Can you fix the errors? Please still use header files iostream header files. This is a topic under Data Structures: Arrays.
//Start of program
#include <iostream>
using namespace std;
int main()
{
//Declare array and initialize variables
int a[50], sum = 0, i;
//Prompt the user
cout << "Enter 50 values of integer array: \n";
//For loop
for (i = 0; i < 50; i++)
{
cin >> a[i];
}
//Odd-indexed numbers
for (i = 0; i < 50; i++)
{
if (a[i] % 2 != 0) //If the remainder when element at i is divided by 2 yields a non-zero value
{
continue; //Iteration repeated wherein element at i is incremented and tested
}
sum += a[i]; //Statement executed and iteration continued
}
//Prompt the message with the sum of odd-indexed numbers
cout << "The sum of odd-indexed numbers are: " << sum << endl;
//End of program
return 0;
}
Step by step
Solved in 3 steps with 1 images
- In c++, please! Thank you! Write a void function SelectionSortDescendTrace() that takes an integer array and sorts the array into descending order. The function should use nested loops and output the array after each iteration of the outer loop, thus outputting the array N-1 times (where N is the size). Complete main() to read in a list of up to 10 positive integers (ending in -1) and then call the SelectionSortDescendTrace() function. If the input is: 20 10 30 40 -1 then the output is: 40 10 30 20 40 30 10 20 40 30 20 10 The following code is given: #include <iostream> using namespace std; // TODO: Write a void function SelectionSortDescendTrace() that takes// an integer array and the number of elements in the array as arguments,// and sorts the array into descending order.void SelectionSortDescendTrace(int numbers [], int numElements) { } int main() { int input, i = 0; int numElements = 0; int numbers [10]; // TODO: Read in a list of up to 10 positive…you will develop a c++ program to sort the elements of a character array in descending order. Your program should ask the user to input 7 elements (of type char) for the array and sort it. For instance, if the user enters d a b e c x g, your program should display: x g e d c b a Note: You cannot use the built-in sort function. Also, you can assume that the user only enters lower-case characters.In C++ Please help (Count occurrence of each letter in a string) Write a function that counts the occurrence of each letter in the string using the following header: void count (const char s[], int counts []) where counts is an array of 26 integers. counts [0], counts [1], ..., and counts [25 ] count the occurrence of a, b, ..., and z, respectively. Letters are not case-sensitive, i.e., letter A and a are counted the same as a.Write a test program that reads a string, invokes the count function, and displays the non-zero counts as shown in the following sample run: (Note that c: 1 time are separated by exactly one space.)Show the Sample Output Using the Preceding InputExecution Result: command>Exercise07 37Enter a string: Welcome to New York!c: 1 timee: 3 timesk: 1 timeL: 1 timem: 1 timen: 1 timeO: 3 timesr: 1 timet: 1 timew: 2 timesy: 1 time
- In this lab, you complete a partially written C++ program that reverses the order of five numbers stored in an array. The program should first print the five numbers stored in the array. Next, the program passes the array to a function where the numbers are reversed. The program then prints the reversed numbers in the main program. The source code file provided for this lab includes the necessary variable declarations. Comments are included in the file to help you write the remainder of the program. // Reverse.cpp - This program reverses numbers stored in an array. // Input: None // Output: Original contents of array and the reversed contents of the array. #include <iostream> #include <string> using namespace std; void reverseArray(int[]); int main() { int numbers[] = {9, 8, 7, 6, 5}; int x; // Print contents of array // Call reverseArray() function here // Print contents of reversed array return 0; } // End of…write a program in c++ that prompts the used to enter 50 intergers and stores them in an array. the program then determines and outputs which numbers in the array are sum of the two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs. use the below code to write the defention of the functions. #include <iostream> #include <iomanip> using namespace std; void initialize(double list[], int size); void print(double list[], int size); int main() { double alpha [50]; initialize(alpha, 50); print(alpha, 50); return 0; }I wrote this c++ program to find min and max, but why does the program say it cannot find the min and max. WHere I got wrong? Please help me revise my code. I have must use the pointer and void function in my code. Please help me revise it. #include <iostream>using namespace std; int getmin(int number[], int size){ int min=number[0]; for (int i=1; i<size; i++) { if (number[i]<min) min=number[i]; } return min;}int getmax(int number[], int size){ int max=number[0]; for (int i=1; i<size; i++) { if (number[i]>max) max=number[i]; } return max;}void getminandmax(int number[], int size, int* min, int* max) { for (int i=1; i<size; i++) { if (number[i] > *max) *max=number[i]; if (number[i] < *min) *min=number[i]; } } int main(){ int number[5]={5, 4, -2, 29, 6}; int min=number[0]; int max=number[0]; getminandmax(number, 5, &min, &max);…
- Program in c please. Get array lenght and elements from the user. Print that array in reverse order. Only print array in reverse array don't reverse the arrayFor a given array arr[6]-{1,3,10,12,6,9}. 3 Write a C++ program which creates the cummulative sum array named csum[6] for the given array. Cummulative sum array is a array where value at every index i stores the sum of elements from index @ to i of given array arr. Note- I dont need any input or functions, simply create the csum array for given arr and print it.For this project the program should be made in C++ Write a menu driven program that reads an array of 10 integer from standard keyboard (user) utilizing a loop and outputs the following depending on user's choice Choice 1 - Prints the elements of array Choice 2 - Prints the minimum value of the array Choice 3 - Prints the maximum value of the array Choice 4 - Prints the product of all the numbers utilizing a loop. Choice 5 - Prints the sum of all the numbers utilizing a loop Choice 6- Print the elements of array in a reverse order When the program is done, your program should ask the user if they would like to enter another set of 10 numbers and the program should repeat itself. Input validation: Your program should only accepts integers.
- I need a short program that takes in a string of characters such as: "-3 44 * 2 +" and puts the numbers into an array and that handles the negative sign. So the array will be: [-3,44,2] Please write in C++Please take note that: The strings we are using in this program are C-strings You cannot use C++ Strings You cannot use any library function other than the overloaded operator Use of dynamic 2-d array is mandatory P.S. This is different from my previous question, so if you try to answer with the same solution it's automatically a markdown.C++ Program - Arrays- Chapter 7 Include the following header files in your program: string, iomanip, iostream This program is to have no programmer created functions. Just do everything in main and make sure you comment each step. Also, this program will be expanded in Chapter 9 to use pointers. Create a program which has: 1. The following arrays created: a. an array of double with 5 elements, dArr b. an array of long, lArr, with 7 elements and initialized at the time of creation with the values 100000, 134567, 123456, 9, -234567, -1, 123489 c. a 2 dimensional array of integer, with 3 rows and 5 columns, iArr. d. an array of char with your name initialized in it. Big enough for 30 typable characters, sName. 2. define 3 variables, , cnt1 and cnt2 (short data types) as general purpose counters and a long double total 3. define 1 long variable called highest 4. a for loop to put a random number into each of the elements of the array of double, dArr. Use rand() and seed a random starting…