number of elements in an array between upper and lower bounds program
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#define MAX_SIZE 100
#define UPPER_BOUND 100
#define LOWER_BOUND 0
int main()
{
int Num[MAX_SIZE],n=0,SEED=1,Count=0;
srand(SEED);
for(n=0;n<MAX_SIZE;n++)
{
Num[n] = rand();
if(Num[n]>=LOWER_BOUND && Num[n]<+UPPER_BOUND) Count++;
}
printf("\n\tLower Bound = %d",LOWER_BOUND);
printf("\n\tUpper Bound = %d",UPPER_BOUND);
printf("\n\tno. of elements betwee lower and upper bound = %d",Count);
return(0);
}
Comments
Leave a comment