Question: Given an integer array Arr of size N the task is to find the count of elements whose value is greater than all of its prior elements. Note: 1st element of the array should be considered in the count of the result. For example, Arr]={7,4,8,2,9} As 7 is the first element, it will consider in the result. 8 and 9 are also the elements that are greater than all of its previous nents. Since total of 3 elements is present in the array that meets the condition. Hence the output = 3. Example 1: Input 5-> Value of N, represents size of Arr 7-> Value of Arr[0] 4-> Value of Arr[1] 8-> Value of Arr[2] 2-> Value of Arr[3] 9-> Value of Arr[4] Output: 3

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter12: Points, Classes, Virtual Functions And Abstract Classes
Section: Chapter Questions
Problem 29SA
icon
Related questions
Question

 

 

Question: Given an integer array Arr of size N the task is to
find the count of elements whose value is greater than all of
its prior elements.
Note: Ist element of the array should be considered in the
count of the result.
For example,
Arr] {7,4,8,2,9}
As 7 is the first element, it will consider in the result.
8 and 9 are also the elements that are greater than all of its
previous elements.
Since total of 3 elements is present in the array that meets
the condition.
Hence the output = 3.
Example 1:
Input
5 -> Value of N, represents size of Arr
7-> Value of Arr[0]
4 -> Value of Arr[1]
8-> Value of Arr[2]
2-> Value of Arr[3]
9-> Value of Arr[4]
Output:
3
Transcribed Image Text:Question: Given an integer array Arr of size N the task is to find the count of elements whose value is greater than all of its prior elements. Note: Ist element of the array should be considered in the count of the result. For example, Arr] {7,4,8,2,9} As 7 is the first element, it will consider in the result. 8 and 9 are also the elements that are greater than all of its previous elements. Since total of 3 elements is present in the array that meets the condition. Hence the output = 3. Example 1: Input 5 -> Value of N, represents size of Arr 7-> Value of Arr[0] 4 -> Value of Arr[1] 8-> Value of Arr[2] 2-> Value of Arr[3] 9-> Value of Arr[4] Output: 3
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Arrays
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++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage