420,645 views
15 votes
15 votes
a list of numbers has n elements, indexed from 1 to n. the following algorithm is intended to display the number of elements in the list that have a value greater than 100. the algorithm uses the variables count and position. steps 3

User Jithu
by
2.6k points

1 Answer

21 votes
21 votes

For loop in Python:

...

...

for i in range(n):

if(a[i]>100):

count +=1

else:

continue

print(count)

For loop in C++:

...

...

for(int i=0;i<sizeof(a);i++) {

if(a[i]>100) {

count++;

} else {

;;

}

}

std::cout << count;

User Xcorat
by
2.6k points