A task about RANDOM and massives

Hi, its been i while since i needed some help, but i can't seem to wrap my head around this:

The task: Make a program, which asks user [a,b] a and b borders and says how many elements from the Massive A[100] is in the borders of [a,b][ Make sure that the massive borders are from [1;..100] and with random numbers.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
int main()
{
clrscr();
int A[100], a, b, ;
randomize();

cout<< "Input a  ";
cin>> a;
cout<< "Input b  ";
cin>> b;
if (a<b)


}
getch(); 


Thoughts on what should i do next?

Any help appreciated.
set total to zero
for each element in A
{
if the element value is between the value a and the value b, add one to the total.}
how can i write that? maybe i should include ''for'' cycle?

instead of if i dunno
Last edited on

set total to zero
int total=a;

for each element in A
for (int i=0; i<100; i++)

{
if the element value is between the value a and the value b, add one to the total.}
1
2
3
{ if ((A[i] > a) && (A[i] < b) || (A[i] > b) && (A[i] < a))
  { total++;}
}


If this really was something you couldn't come up with yourself, you need to go back a few steps and go over the very basics of loops.
Last edited on
Topic archived. No new replies allowed.