Write a function that receives an ancay of integers of size 10. The function ( caled RemoveOdds should check the valves Hores in the amay . If a value is odit replace with an even value by multiplying it wilh the number 2 in the value even then replace it with its negalive value Triest the contents at the array back in the main function ono il values are changed .
Hi ,
As per i understood the question , I answered and write the code.
please find the code.
also find the comments for better clarification -
// --------------------------------------------------------------------------------------------------------------------------
#include <stdio.h>
// creating functions for RemoveOdds
int* RemoveOdds(int test[]){
int i =0;
// performing actions
while ( i < 10 ){
if (test[i]%2 != 0) {
test[i] = test[i]*2;
}
i = i + 1;
}
// return updated array
return test;
}
int main()
{
// creating sample test array
int test[10] = { 1,4,6,3,14,13,6,8,44,21};
int* final_output;
int* output;
// first time call function to RemoveOdds
output = RemoveOdds(test);
// to test updated array again as you mentioned in question
final_output = RemoveOdds(output);
int i=0;
// print array
while ( i < 10 ){
printf("%d\n",final_output[i]);
i = i + 1;
}
return 0;
}
//-----------------------------------------------------------------------------------------------------------------------------------
Note -
1.
We used int* funcname , function is going to return int array .
if we use int function , it means it will return int value so we used int*.
2.
I call the RemoveOdds twice.
As per you question , first time for removing the odds and update the value.
second time for checking , the updated array again.
output -
![int* RemoveOdds(int test[]){ 4 5 6 7 8 9 int i =0; // performing actions while (i < 10 ) { if (test[i]%2 != 0) { tact tect*2.](http://img.homeworklib.com/questions/f214ed50-cec6-11eb-ab16-1f9fdbf51c0f.png?x-oss-process=image/resize,w_560)
If you feel , something needs to be correct or clear. Please mention in comment.
Thank You.
Write a function that receives an ancay of integers of size 10. The function ( caled...
Write in C.
Write a function that takes an array of integers and its size as parameters and prints the two largest values in the array. In this question, the largest value and the second largest value cannot be the same, even if the largest value occurs multiple times. In the first sample, the two largest values are 9 and 8 (even though the value 9 appears twice). In the second sample, all the values are equal and the program...
c++ write a function that has 3 parameters, two arrays of integers of the same size , and the size of the arrays. the function should add the two arrays and store the results in a third array, then print out the contents of the third array name it arraya
(C++)Write a function that accepts an int array and the array’s size as arguments.The function should create a new array that is twice the size of the argument array.The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0.The function should return a pointer to the new array.Demonstrate the function by using it in a main program that reads an integer N (that is not more...
In C++ Write a function that receives an integer array with its size and determines whether the array is already sorted in increasing order. Write a test program (main function) that prompts the use to enter a list and displays whether the list is sorted or not. The first number in the input indicates the size of the list. Assume the maximum list size is 20.
In C++ Write a function that receives an integer array with its size and determines whether the array is already sorted in increasing order. Write a test program (main function) that prompts the use to enter a list and displays whether the list is sorted or not. The first number in the input indicates the size of the list. Assume the maximum list size is 20.
Write a complete Java program in a file caled Module1Progrom.java that reads all the tokens from a file named dota.txt that is to be found in the same directory as the running program. The program should ignore al tokens that cannot be read as an integer and read only the ones that can. After reading all of the integers, the program should print all the integers back to the screen, one per line, from the smalest to the largest. For...
IN C++ Write a function numberOfOddNumbers that takes an array of integers and its size (length) as parameters and then returns the number of the odd numbers found in the array. For example, if an array called list stores the following values: int list []= { 1,1, 8,6,9,4,3,9595,0 }; Then the call of numberOfOddNumbers (list,9) should return 5. If instead, the list had stored these values: int list2[] = { 2, 4, 6, 8, 10, 208 }; Then the call...
Write a function to have a user enter some number of integers into an array. The integer values must be between -100 and +100 inclusive (+100 and -100 should be accepted as valid inputs). The integer array and the size of the array are passed into the function through parameters. Do not worry about includes. This is only a function, so there is no main routine. The function should fill the array with valid inputs. For invalid input values, inform...
1. Write a function named findTarget that takes three parameters: numbers, an array of integers - size, an integer representing the size of array target, a number The function returns true if the target is inside array and false otherwise 2. Write a function minValue that takes two parameters: myArray, an array of doubles size, an integer representing the size of array The function returns the smallest value in the array 3. Write a function fillAndFind that takes two parameters:...
Write a C++ function, smallestIndex, that takes as parameters an
int array and its size and returns the index of the first
occurrence of the smallest element in the array. To test your
function, write a main that prompts a user for a list of 15
integers and outputs the index and value of the first occurrence of
the smallest value.
The program should print out
Enter 15 integers:
The position of the first occurrence of the smallest element in...