10.
7. Write a macro named mGenRandom that generates a random integer between 0 and n-1. Let n be the only parameter.
If you have any doubts, please give me comment...
#define mGenRandom(n) (rand()%n)
Example:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define mGenRandom(n) (rand()%n)
int main(){
srand(time(NULL));
int num = mGenRandom(5);
printf("%d\n", num);
return 0;
}
10. 7. Write a macro named mGenRandom that generates a random integer between 0 and n-1....
10 5. Create a structure named MyStruct containing two fields: field1, a single word, and field2, an array of 20 doublewords. The initial values of the fields may be left undefined. 6. Declare a variable as an array of 20 MyStruct objects. 7. Write a macro named mGenRandom that generates a random integer between 0 and n-1. Let n be the only parameter. 8. What is the purpose of the IFB directive?
C++ language Write a program that 1. generates a random integer between 100 and 1000, call the number N 2. reads a file name from the keyboard 3. opens a file for output using the file name from step 2 4. generates N random numbers between 1 and 100 and writes them to the file from step 3 5. closes the file 6. opens the file from steps 3, and 4 for input 7. reads the numbers from the file...
Write a method named RandomDoubles that takes a parameter N as its argument and generates N random double values where each double value is a random double between 0.0 and 0.9999…. (i.e. simply use Math.random()) and save these double values into a file named doubles.txt.(java please) Next, write the following method that returns the number of digits in the fractional part of a double value. For example, 12.345 has 3 digits in the fractional part, 1.2345 has 4 digits in...
1.Write a PHP function that generates a random email. 2.Write a PHP function that generates a random password given the length as a parameter. 3. Run a query that will generate a database named lab4 b. 4.Run a query that will create a table named users, the table will only have three columns, email TEXT and password TEXT, ID INTEGER NOT NULL AUTO_INCREMENT. ID will be the primary key that will be generated for us automatically based on the record...
Write a C program that generates one hundred random integers between 0 and 9 and displays the count for each number. (Hint: Use rand()%10 to generate a random integer between 0 and 9. Use an array of ten integers, say counts, to store the counts for the number of 0’s, 1’s,…..,9’s.)
Problem: Write a program that generates random numbers between 1 and 10 and fill an array of size 20 with them. Have your program sort the array then output in order the number of occurrences of each random number generated. Use the STL sort function to sort your array. How to use the STL sort: #include <algorithm> ... int a[20] ... sort(a,a+20); Example Output: This program generates random numbers and tabulates the results Original List Sorted: a[ 0] 1 a[...
In JAVA, write a program that generates 10 random numbers between 0 and 9. Use count arrays for each number. A sample output would be: The 10 random numbers are: 5 7 1 9 0 0 1 2 3 4 0 occurs 2 times 1 occurs 2 times 2 occurs 1 time 3 occurs 1 time 4 occurs 1 time 5 occurs 1 time 6 occurs 0 times 7 occurs 1 time 8 occurs 0 times 9 occurs 1 time
Write a recursive function named arithmeticSum that takes a positive integer parameter n and returns the sum of the integer numbers from 1 to n Please write in C++
Write a program that generates a list of 50 random integers such that the first integer number is between 1 and 2 (including 2), the second is between 1 and 3, the third is between 1 and 4, . . . , and the last is between 1 and 51.
A certain machine randomly generates an integer between 1 and 9, inclusive. The machine generates n numbers, and all the outputs are multiplied together. What is the probability that the resulting product is divisible by 10?