1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zlopas [31]
2 years ago
12

Type a statement using srand() to seed random number generation using variable seedVal. Then type two statements using rand() to

print two random integers between (and including) 0 and 9. End with a newline. Ex:
5.
7.
Note: For this activity, using one statement may yield different output (due to the compiler calling rand() in a different order). Use two statements for this activity. Also, after calling srand() once, do not call srand() again. (Notes)
1 #include
2 #include //
3 Enables use of rand ()
4 int main(void) ( int seedval;
6.
7. scanf ("%d", &seedval);
8.
9.
10 srand(int seedval);
11 printf("%d\n", srand());
12 printf("%d\n", srand());
13
14 return e;
15 }
Computers and Technology
1 answer:
Alik [6]2 years ago
8 0

Answer:

#include<stdio.h>

#include<stdlib.h>

int main(void){

int seedval;

scanf ("%d", &seedval);

srand(seedval);

printf("%d\n", rand()%10);

printf("%d\n", rand()%10);

 return 0;

}

Explanation:

The given code is poorly formatted. So, I picked what is usable from the code to write the following lines of code:

#include<stdio.h>

#include<stdlib.h>

int main(void){

This line declares seedval as integer

int seedval;

This line gets user input for seedval

scanf ("%d", &seedval);

This line calls the srand function to generate random numbers

srand(seedval);

This prints a random number between 0 and 9

printf("%d\n", rand()%10);

This also prints a random number between 0 and 9

printf("%d\n", rand()%10);

 return 0;

}

You might be interested in
What happens when the computer is thrashing? quizzlet?
lutik1710 [3]
When computers need to use more memory than have RAM, they'll swap out pages of memory to their drive. When they need those memory pages, they'll swap out others and swap in the needed ones. If a computer needs enough additionall memory, it can get so busy swapping that it doesn't have any (or very little) time to do any useful work. That is called thrashing.

Unix calls swapping swapping. Windows calls it paging, probably because of the memory pages. Memory pages are 4096 (4KB) sections of memory.

Unix drives are usually partitioned with a swap partition, and swap files can be made in the filesystem. Windows just has pagefiles[s].
5 0
3 years ago
Plane eyes I don't know
FrozenT [24]
IFLY is probably what it was.
3 0
3 years ago
Which word most strongly appeals to pathos?
const2013 [10]

Answer:

I think it would be unfulfilled

6 0
3 years ago
Write a recursive method named binarySearch that accepts a sorted array of integers and an integer target value and uses a recur
djyliett [7]

Answer:

10

-1

Process finished with exit code 0

Explanation: see code bellow

public class BinarySearchRecursive {

   public static int binarySearch(int[] a, int key) {

       return binarySearchRecursiveHelper(a, key, 0, a.length - 1);

   }

   public static int binarySearchRecursiveHelper(int[] arr, int target, int start, int end) {

       if (start > end) {

           return -1;

       }

       int mid = (start + end) / 2;

       if (arr[mid] == target) {

           return mid;

       } else if (target < arr[mid]) {

           return binarySearchRecursiveHelper(arr, target, start, mid - 1);

       } else {

           return binarySearchRecursiveHelper(arr, target, mid + 1, end);

       }

   }

   public static void main(String[] args) {

       int[] a = {-4, 2, 7, 10, 15, 20, 22, 25, 30, 36, 42, 50, 56, 68, 85, 92, 103};

       int index = binarySearch(a, 42);   // 10

       System.out.println(index);

       index = binarySearch(a, 66);   // -1

       System.out.println(index);

   }

}

6 0
3 years ago
Describe a situation in which a robot may have to avoid an obstacle without coming to a complete stop before turning.
Airida [17]

A robot may have to avoid an obstacle without coming to a complete stop before turning. If the robot is able to make a wide enough, long turn. instead of stopping, then turning sharply. For example if the robot were to come across an object and can sense said object before hand. it can then take action into turning before it is close enough.

3 0
3 years ago
Read 2 more answers
Other questions:
  • Define the method object inc_num_kids() for personinfo. inc_num_kids increments the member data num_kids. sample output for the
    11·1 answer
  • . Reorder the following efficiencies from smallest to largest:
    9·1 answer
  • What does it mean to say that two variables are negatively correlated?
    6·1 answer
  • 1. Itemise the order in which BASIC executes arithmetic operation.
    13·1 answer
  • A web page ____ can also create a style sheet that takes precedence over the internal style sheets of browsers.
    10·1 answer
  • Which type of loan is based on financial need
    6·1 answer
  • WILL MARK CORRECT ANSWER AS BRAINLIEST PLSSSS HELP!
    13·2 answers
  • Write a program that allows the user to enter their name from the keyboard. Allow the user to pick how many times they want thei
    12·1 answer
  • What would a system unit that is integrated with the display and keyboard would be considered?
    6·1 answer
  • What does it mean when someone silences notifications?.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!