Explanation:
Not sure what level that's at, or how you're expected to manage memory, so I'll write it in a "safe" manner and you can adjust accordingly.
Notably, I'm allocating memory dynamically at the moment. If you're not used to that, you might want to change that. Also, the c compiler I'm using (gcc) doesn't handle the bool type, so I used int. You may need to change that.
Also, if you change it to use fixed arrays instead of malloc, realloc and free, then you don't need to include stdlib.h.
The code below builds successfully with gcc, so if you have any issues, it will be in translating to another compiler/language.
Answer:
#include <stdio.h>
#include <stdlib.h>
int isArrayOdd(int *inputVals, int numVals){
int n, rval = 1;
for(n = 0; n < numVals && rval; n++){
rval &= inputVals[n] & 1;
}
return rval;
}
int isArrayEven(int *inputVals, int numVals){
int n, rval = 1;
for(n = 0; n < numVals && rval; n++){
rval &= 1 - (inputVals[n] & 1);
}
return rval;
}
int main(void) {
/*
I'm writing this to allow any quantity of numbers,
using malloc to allocate the memory for them dynamically.
You may want to modify this to match the level that your
class is in.
*/
int *numbers, quantity = 0, input;
numbers = (int *) malloc(sizeof(int));
printf("Please enter a number, or hit \"q\" to quit: ");
while(scanf("%i", &input) == 1){
quantity++;
numbers = (int *) realloc(numbers, quantity * sizeof(int));
numbers[quantity - 1] = input;
printf("\nyou entered %i\n", numbers[quantity - 1]);
}
if(isArrayOdd(numbers, quantity)){
printf("all odd\n");
}else if(isArrayEven(numbers, quantity)){
printf("all even\n");
}else{
printf("not even or odd\n");
}
free(numbers);
return 0;
}
=================================================================
BONUS! BONUS! BONUS! BONUS! BONUS! BONUS! BONUS!
=================================================================
The inefficiency of the logic dictated in the assignment drove me nuts, so here's one that's ridiculously simpler and does exactly the same job:
#include <stdio.h>
int main(void) {
int input, oddEven = -1;
printf("Please enter a number, or hit \"q\" to quit: ");
while(scanf("%i", &input) == 1){
printf("\nyou entered %i\n", input);
if(oddEven == -1){
oddEven = input & 1;
}else if(oddEven != (input & 1)){
oddEven = 2;
}
}
switch(oddEven){
case 0:
printf("The numbers are all even\n");
break;
case 1:
printf("The numbers are all odd\n");
break;
case 2:
printf("The numbers are both odd and even\n");
break;
default:
// should never happen
printf("Something odd happened.");
}
return 0;
}
Note that common skills are listed toward the top, and less common skills are listed toward the bottom. According to O*NET, what are common skills needed by Secondary School Special Education Teachers? Check all that apply.
instructing
installation
learning strategies
repairing
active listening
technology design
Answer:
A. Instucting C. Learning Strategies E. Active Listening
Explanation:
Got it right on assignment
input("Enter a number: ")
print(num * 9)
Note that in the above case, if a person save the input as num,
this will print the input 9 times.
How do you go about this code?Therefore, since there is 9 times:
So
num = input("Enter a number: ")
print(num * 9)
If a person actually want to do a real math calculations, then one need to input needs to be inside the number.
num = float(input("Enter a number: "))
print(num * 9)
This is one that do not bring about any errors where the user do not input a number.
Learn more about coding from
https://brainly.com/question/23275071
#SPJ1
If you had to make a choice between studies and games during a holiday, you would use the _______ control structure. If you had to fill in your name and address on ten assignment books, you would use the ______ control structure.
The answers for the blanks are Selection and looping. Saw that this hasn't been answered before and so just wanted to share.
The missing words are "if-else" and "looping".
What is the completed sentence?If you had to make a choice between studies and games during a holiday, you would use the if-else control structure. If you had to fill in your name and address on ten assignment books, you would use the looping control structure.
A loop is a set of instructions in computer programming that is repeatedly repeated until a given condition is met. Typically, a process is performed, such as retrieving and modifying data, and then a condition is verified, such as whether a counter has reached a predetermined number.
Learn more about looping:
https://brainly.com/question/30706582
#SPJ1
Laptop is a small computer which may run with battery.
True or false....
Answer:
True
Explanation:
True all devices unless hooked up to a charger will run out of battery
Answer:
TRUE IS THE ANSWER
I HOPE IT IS HELPFUL
Comments should Your answer: rephrase the code it explains in English be insightful and explain what the instruction's intention is only be included in code that is difficult to understand be used to define variables whose names are not easy to understand
Answer:
(b) be insightful and explain what the instruction's intention is.
Explanation:
Required
Which describes a comment in options (a) to (d)
Comments are not meant to replace the original code but to explain what the code is meant to do; so that even if the code gets to a non-programmer, the person will understand what the code is all about.
From (a) to (d), only option (b) fits the above description.
helllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllo
Hi, I have to make this at least 20 characters long
1) what kind of software is adobe after effects? a) Motion Picture b) Motion Frame c) Motion Graphics d) Motion Dymamics
Answer:motion graphics
Explanation:
adobe after effects can take images and animate them, hense motion graphic. you can make text boxs move, images move. i use the software im dead certain its for motion graphics
The accurate response to the query is option C, which is Motion Graphics.
Adobe After Effects is a software application developed by Adobe Systems that deals with digital visual effects, motion graphics, and compositing. It is extensively utilized in the post-production phase of filmmaking, television production, and animation. After Effects is mainly utilized to produce visual effects and motion graphics for web-based content, DVDs, movies, and videos.
Therefore, option C, which is Motion Graphics, is the correct answer.
when attached to another command, what does the forever block do in scratch? HURRY PLEASE
Answer: it means that it will keep doing that command the whole time
Explanation:
Answer:
The forever command will repeat whatever command is inside of the forever bracket... forever.
Explanation:
the differencebetween browser and search engine
please my assignment have50 mark
Answer:
A browser is a piece of software that retrieves and displays web pages; a search engine is a website that helps people find web pages from other websites.
How do advertisers use data to know which products would most likely appeal to you
Answer:
it gives children or adults something to think about
Explanation:
You have written a program to keep track of the money due to your company. The people in accounting have entered the information from the invoices they have sent out. However, the total from accounting does not agree with a total of a second listing of items that can be billed from the production department.
Using the drop-down menus, complete the sentences about the steps in the debugging process.
As a first step in diagnosing the problem, you will
✔ reproduce the error.
A good place to begin is by examining the
✔ error codes.
Next, you can
✔ troubleshoot
the problem.
This will help you
✔ identify the source of the problem.
Answer:
1. REPRODUCE THE ERROR
2. ERROR CODES
3. TROUBLESHOOT
4. IDENTIFY THE SOURCE OF THE PROBLEM
Explanation:
Debugging a program simply means a sequence of steps which one takes to correct an imperfect program, that is a program that does not run as intended.
A good way to start debugging is to run the code, by running the code, one will be able to determine if the program has a bug. If it has then it produces an error. This error is a good starting point as the error code gives a headway into where the bug may lie.
The error code gives a hint into the type of error causing a program to malfunction which could be a syntax error, logic, Runtime and so on. In some case probable lines where there error lies are spotted and included in the error code produced.
After evaluating the error code, then we troubleshoot the probable causes of the error. By troubleshooting all the possible causes, the source of the error will eventually be identified.
Answer:
As a first step in diagnosing the problem, you will
✔ reproduce the error.
A good place to begin is by examining the
✔ error codes.
Next, you can
✔ troubleshoot
the problem.
This will help you
✔ identify the source of the problem.
Explanation:
website is a collection of (a)audio files(b) image files (c) video files (d)HTML files
Website is a collection of (b) image files (c) video files and (d)HTML files
What is websiteMany websites feature a variety of pictures to improve aesthetic appeal and provide visual substance. The formats available for these image files may include JPEG, PNG, GIF, or SVG.
To enhance user engagement, websites can also introduce video content in their files. Web pages have the capability to display video files either by embedding them or by providing links, thereby enabling viewers to watch videos without leaving the site. Various formats such as MP4, AVI and WebM can be utilized for video files.
Learn more about website from
https://brainly.com/question/28431103
#SPJ1
Expectation on Information Technology Fundamental
You can expect to develop an understanding of information systems, programming languages, information management and artificial intelligence, leaving your studies with the ability to apply your knowledge to solve problems.
When replacing the motherboard of an hp which type of motherboard you use
Answer:
When replacing the motherboard of an HP computer, you need to make sure that the new motherboard is compatible with the computer's model number and specifications. The best option would be to use a motherboard that is specifically designed for your computer model or one that meets the same specifications as the original motherboard. You can usually find this information by checking the user manual or contacting HP support. It's important to ensure that the replacement motherboard has the same socket type as the old motherboard to ensure that the processor is compatible. Additionally, you need to make sure that the new motherboard has the same or compatible ports, such as USB, audio, and Ethernet, to ensure that all the peripherals can be connected to the computer.
#, what is File operation example ?
A file operation example is:
# Opening a file in write mode
file = open("example.txt", "w")
# Writing to the file
file.write("Hello World!")
# Closing the file
file.close()
# Opening a file in read mode
file = open("example.txt", "r")
# Reading the contents of the file
content = file.read()
# Printing the contents of the file
print(content)
# Closing the file
file.close()
File operations are basic tasks performed on a computer file such as reading, writing, copying, moving, and deleting.
This example opens a file named "example.txt" in write mode, writes "Hello World!" to the file, closes it, opens the file in read mode, reads its contents and prints it to the console, and finally closes the file again.
Read more about file operation here:
https://brainly.com/question/28578925
#SPJ1
Suppose datagrams are limited to 1500bytes including IP header of 20 bytes. UDP header is 8 bytes. How many datagrams would be required to send an MP3 of 80000 bytes
Answer:
55
Explanation:
Create a python program that asks the user to input the subject and mark a student received in 5 subjects. Output the word “Fail” or “Pass” if the mark entered is below the pass mark. The program should also print out how much more is required for the student to have reached the pass mark.
Pass mark = 70%
The output should look like:
Chemistry: 80 : Pass: 0% more required to pass
English: 65 : Fail: 5% more required to pass
Biology: 90 : Pass: 0% more required to pass
Math: 70 : Pass: 0% more required to pass
IT: 60 : Fail: 10% more required to pass
The program asks the user to enter their scores for each subject, determines if they passed or failed, and calculates how much more they need to score in order to pass. The percentage needed to pass is never negative thanks to the use of the max() method. The desired format for the results is printed using the f-string format.
Select the correct text in the passage.
Which of the following statements is true with regards to satellite Internet access?
It is cheap.
It is the slowest internet access technology.
It can be used in rural and remote areas.
It requires direct line-of-sight to work.
It requires major installation of new infrastructure.
It covers a large geographical area.
8.1.8: Citation
This uses Python.
Please help me fix this:
def citation (a):
first, middle, last = a
return f"{last}, {first} {middle}"
print(citation(("Martin", "Luther", "King, Jr.")))
# Output
King, Jr, Martin Luther
The code has a SyntaxError because the first line is missing an indentation. In Python, indentation is significant and indicates the start of a block of code. The corrected code would look like this:
The Programdef citation (a):
first, middle, last = a
return f"{last}, {first} {middle}"
print(citation(("Martin", "Luther", "King, Jr.")))
This code would output: King, Jr., Martin Luther.
Read more about python here:
https://brainly.com/question/26497128
#SPJ1
Consider the following program written in C syntax:
void swap(int a, int b) {
int temp;
temp = a;
a = b;
b = temp;
}
void main() {
int value = 2, list[5] = {1, 3, 5, 7, 9};
swap(value, list[0]);
swap(list[0], list[1]);
swap(value, list[value]);
}
. Passed by value-result
Answer:
5=swap 0
Explanation:
becouse it is invalid
explain the impact of the development of science and technology in ancient time to the nation.
Answer:
During the growth of the ancient civilizations,ancient technology was the result from advances in engineering in ancient times.These advances in the history of technology stimulated societies to adopt new ways of living and governance.
Help me with this ……..
Answer:
So is this talking about this pic?
In 25 words or fewer, explain how u can help maintain a productive work environment while on the job
I would ensure side attractions like gisting or surfing the internet while I am supposed to be working are eliminated while also personalizing my space.
You are creating a presentation for your school Photography project and you want to make the pictures stand out. Which tool would be most efficient to use to enhance the images?
A. Symbols
B. Alt text
C. Tables
D. Picture styles
Answer:
D
Explanation:
What would game programmers do when decomposing a task in a modular program?
When decomposing a task in a modular program, game programmers follow a structured approach to break down the task into smaller, more manageable components.
This process is crucial for code organization, maintainability, and reusability. Here's an outline of what game programmers typically do:
1. Identify the task: The programmer begins by understanding the task at hand, whether it's implementing a specific game feature, optimizing performance, or fixing a bug.
2. Break it down: The task is broken down into smaller subtasks or functions that can be handled independently. Each subtask focuses on a specific aspect of the overall goal.
3. Determine dependencies: The programmer analyzes the dependencies between different subtasks and identifies any order or logical flow required.
4. Design modules: Modules are created for each subtask, encapsulating related code and functionality. These modules should have well-defined interfaces and be independent of each other to ensure reusability.
5. Implement and test: The programmer then implements the modules by writing the necessary code and tests their functionality to ensure they work correctly.
6. Integrate modules: Once individual modules are tested and verified, they are integrated into the larger game program, ensuring that they work together seamlessly.
By decomposing tasks into modules, game programmers promote code organization, readability, and ease of maintenance. It also enables parallel development by allowing different team members to work on separate modules simultaneously, fostering efficient collaboration.
For more such questions on programmers,click on
https://brainly.com/question/30130277
#SPJ8
complete the add repair method!
(Will give the brainiest)
Answer:
Give three(3) difference between Dot-matrix printer and the Daisy-wheel printer
How many ads should be implemented per ad group?
A One or two
B Only one
C Three to five
D Two to three
Answer:
only one
Explanation:
because who likes ad
29. Write a program in a script file that calculates the cost of renting a car according to the following price schedule: The program asks the user to enter the type of car (sedan or SUV), the number of days, and the number of miles driven. The program then displays the cost (rounded to cents) for the rent. Run the program three times for the following cases: (a) Sedan, 10 days, 769 miles. (b) SUV, 32 days, 4,056 miles. (c) Sedan, 3 days, 511 miles.
Answer:The price for renting a car at a car rental company is according to the following schedule: Write a MATLAB program in a script file that calculates the cost of renting a car based on the shown price schedule. The program must ask the user to enter the type of car (Sedan or SUV), the number of days, and the number of miles driven. The program then displays the cost (rounded to cents) for the rent in a sentence that reads: "The cost of the rent is XXX $." where XXX is the cost value in $. Run the program three times for the following cases: Sedan, 10 days, 769 miles. SUV, 32 days, 4, 056 miles. Sedan, 3 days, 511 miles. Use fprintf () to display the text and data. The data should be displayed in f format with two decimal digits.
Explanation:
A structure that organizes data in a list that is commonly 1-dimensional or 2-
dimensional
Linear Section
Constant
No answertet provided
It intro technology
Answer:
An array.
Explanation:
An array can be defined as a structure that organizes data in a list that is commonly 1-dimensional or 2-dimensional.
Simply stated, an array refers to a set of memory locations (data structure) that comprises of a group of elements with each memory location sharing the same name. Therefore, the elements contained in array are all of the same data type e.g strings or integers.
Basically, in computer programming, arrays are typically used by software developers to organize data, in order to search or sort them.
Binary search is an efficient algorithm used to find an item from a sorted list of items by using the run-time complexity of Ο(log n), where n is total number of elements. Binary search applies the principles of divide and conquer.
In order to do a binary search on an array, the array must first be sorted in an ascending order.
Hence, array elements are mainly stored in contiguous memory locations on computer.
You decide to test the voltages across several of the components. The measured voltages are:
V1 = 0 Volts
V2 = 12 Volts
V3 = 0 Volts
V4 = 12 Volts
These voltages do not correspond with what should be happening if there is current flowing through each device.
Which statement below describes what is happening?
Zero voltage across the fuse indicates that the fuse is the problem.
12 volts across the resistor and no current indicates that the resistor is blown.
Zero volts across the lamp indicates that the light is bad.
The fuse is bad because there is no current.
Zero volts across the lamp indicates that the light is bad. The correct option is C.
What is resistor?A resistor is a passive two-terminal electrical component used in circuits to implement electrical resistance.
Resistors have a variety of purposes in electronic circuits, including lowering current flow, adjusting signal levels, dividing voltages, biassing active components, and terminating transmission lines.
After the light bulb, a test of 0 volts shows that there is no resistance in the ground circuit.
At that time, the battery is receiving all of the circuit's voltage (by the path of least resistance), and no voltage is passing through the metre (0 volt reading).
Thus, the correct option is C.
For more details regarding resistor, visit:
https://brainly.com/question/24297401
#SPJ1