Answer:
Explanation:
srand function is used to put a seed for random generation so that on every program run, different numbers are generated.
rand() function is used inside a for loop which runs 20 times from i=0 to i=19 and if the number generated is even, only then it is printed, otherwise not.
feel free to comment if you have any doubts!
COde
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
srand(time(0));
for(int i=0; i<20; i++)
{
int n = rand()%101;
if(n%2==0)
printf("%d ", n);
}
return 0;
}
Output:
PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!
PLEASE COMMENT IF YOU NEED ANY HELP!
C language Write a program that generates 20 random integers (ranging in between 0 to 100)...
(C++)Write a program that generates twenty five random integers between 0 and 24 and display the sum of even integers. (Hint: Use rand()%25 to generate a random integer between 0 and 24. Use an array of 25 integers, say num , to store the random integers generated between 0 and 24.)
Write a program that generates 1,000,000 random integers between 0 and 9 and determines the longest consecutive sequence of each of the numbers. The program displays the numbers and their longest consecutive sequence lengths in descending order. in a c++ visual studios 2017
c# prograaming language 1. write a program that generates 10,000 random integers in the range of 0-9 and them in binary search tree. 2. use any sort algorithm (insertion, bubble, quick...) to display a list of each of the integers and how many times they appear. 3. at last, add ruction to the BinarySearchTree class that count the number of edges in a tree. Write a program that generates 10,000 random integers in the range of 0-9 and store them...
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 program that generates an array of one hundred random integers between 0 and 9 and displays the count of each number. C programming
Part II. Write a programming segment that generates 25 random integers between 0 and 99. Place the even numbers in an array called EVEN and then place the odd numbers in an array called ODD. Print the EVEN array and Print the ODD array
4. Write a 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.) this program kinda works but i cant figure out why its making more than 100 random numbers ls) [*] test2.cpp test3.cpp #include<stdio.h> #include<stdlib.h> int main() 4 { int a[14],is...
A. Create a java program that generates 1000 random integers. Write the 1000 random integers to a file using the Formatter class. B. Create a second java program that opens the file with the 1000 integers using the Scanner class. Read in the integers and find and print out the largest, smallest and the average of all 1000 numbers. C. Repeat A from above but use the BufferedWriter class B. Repeat B from above but use the BufferedReader class.
*IN PYTHON* (Count single digits) Write a program that generates 1,000 random integers between 0 and 9 and displays the count for each number. (Hint: Use a list of ten integers, say counts, to store the counts for the number of 0s, 1s, ..., 9s.) Rubric 5 pts: Proper use of list to count occurrences of numbers 5 pts: Proper calculations of counts 5 pts: Proper output Note: No software dev plan or UML required
Write a program in python that generates X random integers Num. Num is a random number between 20 to 50. X is a random number between 10 to 15. Calculate and show the Smallest, Largest, Sum, and Average of those numbers. You are not allowed to use Python functions sample(), min(), max(), average(), sort(), sorted()!! HINTs: to find Smallest.... 1) X is a random number between 10 to 15... for example 11...this determines how many times the loop will happen...