The two dimensional (2-D) array in Figure 3 is initialized with predetermined values of positive and negative numbers. Type and compile the program. 1 Minelude 2 3 int main ( int listnum [5] (2)={2,-3,7,9,-5,0,-8,1,-4,10} ; int 1,3, neg-0, pos-0; 5 for (1-0;i<5; ++) for (j=0;j<1;j++) 10 11 if (listnum (1(]<0) neg++ 12 13 14 else 15 post+ 16 17 18 printf ("Total positive-td, total negative-td\n", pos, neg) ; 19 return 0; 20 } Figure 3 (a) (b) Amend the program so that the process between line 12 to 15 is performed against all elements in listnum. The output should be as follows: Total positive-6, Total negative-4

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 1PP: (Statistics) a. Write a C++ program that reads a list of double-precision grades from the keyboard...
icon
Related questions
Question
3.4 The two dimensional (2-D) array in Figure 3 is initialized with predetermined values
of positive and negative numbers. Type and compile the program.
1 finclude<stdio.h>
2
3 int main ()
int listnum [5] [2]={2,-3,7,9,-5,0,-8,1,-4,10};
int i,j, neg=0, pos=0;
6
7
for (i=0;i<5;i++)
for (j=0;j<1;j++)
10
11
12
if (listnum[i][j]<0)
13
neg++;
14
else
15
post+:
16
17
18
printf ("Total positive=td, total negative=td\n", pos, neg) ;
19
return 0;
20 }
Figure 3
(a)
(b)
Amend the program so that the process between line 12 to 15 is performed
against all elements in listnum. The output should be as follows:
Total positive-6, Total negative-4
Transcribed Image Text:3.4 The two dimensional (2-D) array in Figure 3 is initialized with predetermined values of positive and negative numbers. Type and compile the program. 1 finclude<stdio.h> 2 3 int main () int listnum [5] [2]={2,-3,7,9,-5,0,-8,1,-4,10}; int i,j, neg=0, pos=0; 6 7 for (i=0;i<5;i++) for (j=0;j<1;j++) 10 11 12 if (listnum[i][j]<0) 13 neg++; 14 else 15 post+: 16 17 18 printf ("Total positive=td, total negative=td\n", pos, neg) ; 19 return 0; 20 } Figure 3 (a) (b) Amend the program so that the process between line 12 to 15 is performed against all elements in listnum. The output should be as follows: Total positive-6, Total negative-4
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Fundamentals of Multithreaded Algorithms
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning