
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
![**Task Description:**
Write a for loop to populate the array `userGuesses` with `NUM_GUESSES` integers. Read integers using `scanf`.
Example: If `NUM_GUESSES` is 3 and the user enters 9, 5, and 2, then `userGuesses` is {9, 5, 2}.
**Code Snippet:**
```c
#include <stdio.h>
int main(void) {
const int NUM_GUESSES = 3;
int userGuesses[NUM_GUESSES];
int i;
/* Your solution goes here */
for (i = 0; i < NUM_GUESSES; ++i) {
printf("%d ", userGuesses[i]);
}
printf("\n");
return 0;
}
```
**Explanation:**
The code defines a program that requires user input to fill an array named `userGuesses` with a fixed number of integers (three in this case). Inside the `main` function:
1. `NUM_GUESSES` is set as a constant with a value of 3.
2. An array `userGuesses` of size `NUM_GUESSES` is declared.
3. A placeholder comment indicates where the loop structure to gather user input should be implemented.
4. A for loop iterates over the `userGuesses` array to print each integer separated by spaces.
5. The program ends by returning 0.
**Instructions for Completing the Code:**
Insert a for loop after the comment `/* Your solution goes here */` that uses `scanf` to read integers from the user and fill the `userGuesses` array. Here’s what that might look like:
```c
for (i = 0; i < NUM_GUESSES; ++i) {
scanf("%d", &userGuesses[i]);
}
```](https://content.bartleby.com/qna-images/question/877d147a-40f9-47d8-b25c-41d77d376d71/1ee4692e-f612-41a8-8343-c598f5648eba/6l0zyo_thumbnail.png)
Transcribed Image Text:**Task Description:**
Write a for loop to populate the array `userGuesses` with `NUM_GUESSES` integers. Read integers using `scanf`.
Example: If `NUM_GUESSES` is 3 and the user enters 9, 5, and 2, then `userGuesses` is {9, 5, 2}.
**Code Snippet:**
```c
#include <stdio.h>
int main(void) {
const int NUM_GUESSES = 3;
int userGuesses[NUM_GUESSES];
int i;
/* Your solution goes here */
for (i = 0; i < NUM_GUESSES; ++i) {
printf("%d ", userGuesses[i]);
}
printf("\n");
return 0;
}
```
**Explanation:**
The code defines a program that requires user input to fill an array named `userGuesses` with a fixed number of integers (three in this case). Inside the `main` function:
1. `NUM_GUESSES` is set as a constant with a value of 3.
2. An array `userGuesses` of size `NUM_GUESSES` is declared.
3. A placeholder comment indicates where the loop structure to gather user input should be implemented.
4. A for loop iterates over the `userGuesses` array to print each integer separated by spaces.
5. The program ends by returning 0.
**Instructions for Completing the Code:**
Insert a for loop after the comment `/* Your solution goes here */` that uses `scanf` to read integers from the user and fill the `userGuesses` array. Here’s what that might look like:
```c
for (i = 0; i < NUM_GUESSES; ++i) {
scanf("%d", &userGuesses[i]);
}
```
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

Knowledge Booster
Similar questions
- A for loop is commonly used to iterate over all elements of an array.A. True B. Falsearrow_forwardThe following program is supposed to let the end-user enters 10 numbers in a one dimensional array. The program must then check the input numbers in the following order and way: 1f the input number is a negative one, the program should multiply that number by (5), and return the number of negative elements in the array. 2. if the input number is a positive one, the program should multiply that number by (2), and return the number of positive elements in the array. 3. if the input number is a zero, the program should return the number of zeros in the array The program code is given below with some missing code. You are required to write the missing code ONLY in order to make the program complete. Sample Input/Output Enter 10 numbers in the array -8 -16 16 80 2 12 -12 -2 0 -40 -80 32 16 0 4 24 -60 -10 0 The number of negative elements is: 4 The number of positive elements is: 4 The number of zeros is: 2 dinclude using namespace std; int main() int input[10], i, negative-0, positive-0,…arrow_forwardpython exercise Given the following list: testlist2 = (23,50,12,80,10,90,34,78,4,19,53) Use testlist2 to create Numpy array of int16 and then display the array. Display the number of dimension of testnp. Display the shape of testnp. Display the number of bytes of testnp. Display the mean, sum, max, and min of testnp.arrow_forward
- Programming language: Processing from Java Question attached as photo Topic: Use of Patial- Full Arraysarrow_forwardCORAL LANGUAGE PLEASE Write code that loops through the array userVals. Each iteration: If userVals[i] is less than 25, put userVals[i] to output, and then put "." to output. Else, assign userVals[i] with userVals[i] plus 2. integer iinteger array(5) userVals for i = 0; i < userVals.size; i = i + 1 userVals[i] = Get next input // Your solution goes here Put "\nArray values: " to outputfor i = 0; i < userVals.size; i = i + 1 Put userVals[i] to output Put " " to outputarrow_forward2arrow_forward
- Take arr as any integer array of any size.arrow_forwardPrompt: In Python language, write a function that applies the logistic sigmoid function to all elements of a NumPy array. Code: import numpy as np import math import matplotlib.pyplot as plt import pandas as pd def sigmoid(inputArray): modifiedArray = np.zeros(len(inputArray)) #YOUR CODE HERE: return(modifiedArray) def test(): inputs = np.arange(-100, 100, 0.5) outputs = sigmoid(inputs) plt.figure(1) plt.plot(inputs) plt.title('Input') plt.xlabel('Index') plt.ylabel('Value') plt.show() plt.figure(2) plt.plot(outputs,'Black') plt.title('Output') plt.xlabel('Index') plt.ylabel('Value') plt.show() test()arrow_forward/* (name header) #include // Function declaration int main() { int al[] int a2[] = { 7, 2, 10, 9 }; int a3[] = { 2, 10, 7, 2 }; int a4[] = { 2, 10 }; int a5[] = { 10, 2 }; int a6[] = { 2, 3 }; int a7[] = { 2, 2 }; int a8[] = { 2 }; int a9[] % { 5, 1, б, 1, 9, 9 }; int al0[] = { 7, 6, 8, 5 }; int all[] = { 7, 7, 6, 8, 5, 5, 6 }; int al2[] = { 10, 0 }; { 10, 3, 5, 6 }; %3D std::cout « ((difference (al, 4) « ((difference(a2, 4) <« ((difference (a3, 4) « ((difference(a4, 2) <« ((difference (a5, 2) <« ((difference (a6, 2) <« ((difference (a7, 2) <« ((difference(a8, 1) « ((difference (a9, 6) « ((difference(a10, 4) " <« ((difference(al1, 7) « ((difference (al2, 2) == 10) ? "OK\n" : "X\n"); << "al: << "a2: %3D 7)? "OK" : "X") << std::endl == 8) ? "OK\n" : "X\n") 8) ? "OK\n" : "X\n") == 8) ? "OK\n" : "X\n") == 8) ? "OK\n" : "X\n") == 1) ? "OK\n" : "X\n") == 0) ? "OK\n" : "X\n") 0) ? "OK\n" : "X\n") == 8) ? "OK\n" : "X\n") == 3) ? "OK\n" : "X\n") == 3) ? "OK\n" : "X\n") == << "a3: == << "a4: <<…arrow_forward
- 30arrow_forwardmy code is producing no output.arrow_forwardKim Gigabit purchase items of various quantities; valid quantities are greater than 0 and less than 100Read the quantity for each 10 items from the keyboard and store each into an integer array (use loop); if Kim enters a quantity of 0, negative, or greater than 100, it should be rejected, and she should be queried for a valid entry. After the valid entries are complete, display the unsorted array content, pass the unsorted array to another method for sorting (use for loop), and display of the sorted array. Use javaarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education