Question: Problem 1 : The following program is supposed to count the number of even numbers and the number of odd numbers in an array of

Problem 1:
The following program is supposed to count the number of even numbers and the number of odd numbers in an array of integers that a user enters.
However the program has some errors in style, syntax, logic and runtime.
In a text or doc file, give the line number(s) that the error (or errors) occurs and the type of error and a complete
explanation of the error or errors as well as what the correction would be.
1. #include
2. #include namespace std;
3. int main(){
4. const int even_count;
5. int odd_count;
6. int index;
7. int DATA[10];
8. cout << "Enter 10 numbers: ";
9. cin >> DATA[1]>> DATA[2]>> DATA[3]>> DATA[4]> DATA[5] ;
10. cin >> DATA[6]>>"">> data[7]>> DATA[8]>> DATA[9]>> DATA[10];
11.
12. for (index ==1; index =10; ++index); {
13. if (DATA[index]/2==1)
14.++odd_count;
15. if (DATA[index]%2=0)
16.++even_count;
17. cout << "Number of odds: "<< even_count ;
18.<<" number of evens: "<< odd_count << end;
19. stop 0;
20.}
Name your file Problem1YourName.txt (or .doc) where YourName is your name
Rubric: Every error is noted, what type of error, why it is an error, and the correction is noted.
Problem 2:
A student wrote the following function that was supposed to count the number of times a particular number appeared in an array and
return the count to the calling function. There are many errors in the function, some of them are style errors, and
some of them are programming errors (syntax, logic, runtime). Your job is to identify every error, the type of error,
then fix the error so that the function would work correctly.
1. double COUNTVALUES(integer array, value){
2. int Howmany;
3. for (i =1; i <= array[0]/ sizeof(array); i++){
4. if (array[i]= value) howmany++;
5.}
Grading: full credit for a Problem5YourName.doc or Problem5YourName.txt file that outlines each error and identifies the line number, the error, the type of error (style, syntax, logic, runtime), and why it is an error and a Problem5YourName.cpp file with the correct function.
Note:
Zip all your files together and put onto the Moodle. DO NOT put onto your digication eportfolio.

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 Programming Questions!