In C++ 1. Write a random number generator that has a range from 10-90. 2. Write
ID: 3772009 • Letter: I
Question
In C++
1. Write a random number generator that has a range from 10-90.
2. Write a loop that iterates through a [5][7] array.
a. How many times does that loop iterate?
3.Write a function that calculates the area of a triangle A=1/2b*h;
4.Write a function that runs through an array: int final = {72,60,88,95}.
a.The array and size are provided in the int main
b.Write the call in the int main
c. If the array contains a value of 75 return a 1.
5. When are each of the following utilized?
#include
#include
#include
#include
#include
Explanation / Answer
1. int A = rand()%80 + 10;
2.
for(int i=0;i<5;i++)
for(int j=0;i<7;j++)
cout<<a[i][j];
2. a) 35 times
3)
float area(int b, int h){
float A= .5 * b * h;
return A;
}
4)
int search(int a[],int size){
for(int i=0;i<size;i++)
if(a[i] == 75)
return 1;
return -1;
}
int main(){
int final[] = {72,60,88,95};
int size = 4;
search(final,4)
return 0;
}