Soru
#include <ctime) using namespace std; double func (int, int); int main()( srand(time (NULL)); int n1,n2; cout <<"in Get the first number cin >> n1; cout sc"in Get the second number cin >> n2; cout << func(n1 return 0; double func (int b int a)( double resultzo; /missing code"/ return results ) Select one: resuit=b-rand0% (a+50): resuit-a+rand(% )(b+50) result=a+rand0% (b+51) d. resuit=a+rand0% (b+51-a); my choice
Çözüm
4.7
(303 Oylar)
Rauf
Elit · 8 yıl öğretmeni
Uzman doğrulaması
Cevap
The correct answer is:d.
Explanation: The function `func` is supposed to take two integers as input and return a result. The missing code in the function should generate a random number within a certain range. The correct option is d, which generates a random number between `a` and `b+51-a`. This ensures that the result is always within the range of `a` to `b`.