Question: C++ Arrays, Functions, Loops Write a function that returns the integer representation of a positive integer value stored in a char array. The function must

C++ Arrays, Functions, Loops

C++ Arrays, Functions, Loops Write a function that returns the integer representation

of a positive integer value stored in a char array. The function

Write a function that returns the integer representation of a positive integer value stored in a char array. The function must return -1 if the value in the char array is not a positive integer number (a negative number, a decimal number, an array with characters..) For example, given the input char myNumberl- 12590157 Your function should return the value 12590157 The main function will get from input a divisor and the integer number as a character, and print the result of the division as proof of correctness of the conversion. You can use the pow function from cmath to calculate the power of a number given the base and the exponent double pow(double double). Consider the powers of 10 to calcula 53-1 * 10 A 3 + 4 * 2 + 5 10 " + 3 * 10-o te the final integer value (example: 14 main.cpp 1 #include 4 5 using namespace std; 7enter a data type here charArraytoInt (char myvalue[]) 9 / finish your function definition here / 10 12 13 /DO NOT CHANGE MAIN FUNCTION 14 int main() 15 16 const int MAXSIZE=lee; 17 char myNumber [MAX_SIZE]; 18 float divisor; 19 20cin >> divisor; 21 cin myNumber; 23 if(charArraytoInt (myNumber))20) cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!