162k views
2 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 SidC
by
3.9k points

1 Answer

5 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 Fenix Voltres
by
4.5k points