Write a program that reads a list of integers, and outputs whether the list contains all even numbers, odd numbers, or neither. The input begins with an integer indicating the number of integers that follow. Assume that the list will always contain less than 20 integers.

Ex: If the input is:

5 2 4 6 8 10
the output is:

all even
Ex: If the input is:

5 1 3 5 7 9
the output is:

all odd
Ex: If the input is:

5 1 2 3 4 5
the output is:

not even or odd
Your program must define and call the following two functions. IsArrayEven returns true if all integers in the array are even and false otherwise. IsArrayOdd returns true if all integers in the array are odd and false otherwise.

bool IsArrayEven(int inputVals[], int numVals)

bool IsArrayOdd(int inputVals[], int numVals)





#include

#include



/* Define your function here */



int main(void) {



/* Type your code here. Remember to include the bool library*/



return 0;

}

Answers

Answer 1

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;

}


Related Questions

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

Answers

Answer:

A. Instucting   C. Learning Strategies   E. Active Listening

Explanation:

Got it right on assignment

input("Enter a number: ")
print(num * 9)

Answers

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.

Answers

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....​

Answers

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

Answers

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

Answers

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

Answers

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​

Answers

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

Answers

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

Answers

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.

Answers

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​

Answers

Website is a collection of (b) image files (c) video files and  (d)HTML files​

What is website

Many 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​

Answers

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

Answers

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 ?

Answers

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()


What is a File Operation?

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

Answers

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

Answers

HERE IS THE CODE

pass_mark = 70# Input marks for each subjectchemistry_mark = int(input("Chemistry: "))english_mark = int(input("English: "))biology_mark = int(input("Biology: "))math_mark = int(input("Math: "))it_mark = int(input("IT: "))# Calculate pass or fail status and percentage required to passchemistry_status = "Pass" if chemistry_mark >= pass_mark else "Fail"chemistry_percent = max(0, pass_mark - chemistry_mark)english_status = "Pass" if english_mark >= pass_mark else "Fail"english_percent = max(0, pass_mark - english_mark)biology_status = "Pass" if biology_mark >= pass_mark else "Fail"biology_percent = max(0, pass_mark - biology_mark)math_status = "Pass" if math_mark >= pass_mark else "Fail"math_percent = max(0, pass_mark - math_mark)it_status = "Pass" if it_mark >= pass_mark else "Fail"it_percent = max(0, pass_mark - it_mark)# Output resultsprint(f"Chemistry: {chemistry_mark} : {chemistry_status}: {chemistry_percent}% more required to pass")print(f"English: {english_mark} : {english_status}: {english_percent}% more required to pass")print(f"Biology: {biology_mark} : {biology_status}: {biology_percent}% more required to pass")print(f"Math: {math_mark} : {math_status}: {math_percent}% more required to pass")print(f"IT: {it_mark} : {it_status}: {it_percent}% 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.

Answers

Not cheap

Actually very fast

Works anywhere that you can see the sky (e.g. not 100m underground)

Requires direct line-of-sight

Requires new infrastructure in space (satellites), but small dishes for customers on Earth (so i’d say no)

Yes, satellites of any kind cover 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

8.1.8: Citation This uses Python.Please help me fix this:def citation (a): first, middle, last = a return

Answers

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 Program

def 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

Answers

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.​

Answers

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.

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 ……..

Help me with this ..

Answers

Answer:

So is this talking about this pic?

Help me with this ..

In 25 words or fewer, explain how u can help maintain a productive work environment while on the job

Answers

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

Answers

Answer:

D

Explanation:

I say D would be the answer because the other ones don’t make sense

What would game programmers do when decomposing a task in a modular program?

Answers

When game programmers decompose a task in a modular program, they would typically break down the task into smaller, more manageable modules or functions. Here are some steps they might take during the decomposition process:

1. Identify the overall task or feature: Game programmers start by identifying the larger task or feature they want to implement, such as player movement, enemy AI, or collision detection.

2. Analyze the task: They analyze the task to understand its requirements, inputs, and desired outputs. This helps them determine the necessary functionality and behavior.

3. Identify subtasks or components: They identify the subtasks or components that make up the larger task. For example, in the case of player movement, this could involve input handling, character animation, physics simulation, and rendering.

4. Break down the subtasks further: Each subtask can be further decomposed into smaller, more specific functions or modules. For example, input handling might involve separate functions for keyboard input, mouse input, or touch input.

5. Define interfaces: They define clear interfaces between the modules, specifying how they interact and communicate with each other. This helps ensure modularity and maintainability of the code.

6. Implement and test modules: Game programmers then proceed to implement each module or function, focusing on their specific responsibilities. They can test and iterate on these smaller units of functionality independently.

7. Integrate and test the modules: Finally, they integrate the modules together, ensuring they work harmoniously and produce the desired outcome. Thorough testing is conducted to verify that the overall task or feature functions correctly.

By decomposing tasks in this manner, game programmers can effectively manage the complexity of game development, promote code reusability, enhance collaboration, and facilitate the maintenance and future expansion of the game.

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)

complete the add repair method!(Will give the brainiest)

Answers

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

Answers

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.

Answers

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

Answers

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.

Answers

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

Other Questions
what is the electric charge on a neutron Select the correct answer from each drop-down menu. if a heterozygous male with the genotype ww is mated with a homozygous recessive female of genotype ww, there is a chance that____of the offspring will be heterozygous. W w w Ww www Ww ww if the heterozygous, ww, is crossed with a homozygous dominant, ww, then the probability of having a homozygous recessive offspring is_____. W w W WW Ww W WW Ww what assumption have you made in answering part b Sam rode a bull for 8seconds.Maddie rode a bull for 2 fewer seconds than Sam did.How long did Maddie ride her bull?quick I'll give you 10 points solid state physics probp2. Derive the following dispersion relation of the 2-dimensional square lattice: Ecke.ky) = -2te cos(k, as) aty cos (kgay). What are the 3 types of fat we can consume from food? Which are good for you and which arenot? What is the volume of the composite solid? Use 3.14 for pie and round your answer to the nearest cm3. cylinder height is 2.5 radius : 3 inches, cone is height of 3 inches and radius of inches.(A) 471 cm3 (B) 733 cm3 (c) 707 cm3 (D) 1099cm3 Change the exponential statement to an equivalent statement involving a logarithm.49=72 Find the minimum sample size n needed to estimate for the given values of c, o, and E. c= 0.95, = 5.7, and E = 1 Assume that a preliminary sample has at least 30 members. n= (Round up to the nearest whole number.) $12,000 are deposited into an account with a 7.5% interest rate, compounded annually.Find the accumulated amount after 7 years.Hint: A= P(1+r/k)kt PLease I need help ASAP A student answered 8 out of 10 questions correctly on this quiz. What percent of thequestions were answered correctly? (RLLY NEED HELP) What is caused by friction between two objects?Static electricityDry airA circuitMoist air in eggplant, the deep purple allele cp is incompletely dominant over the white allele cw. if you cross a violet eggplant (cpcw) with a white eggplant (cwcw), what percentage of the progeny will be white? who was involved in the bear river massacre Identify the tables that represent linear functions The graph below does not represent a function. The vertical line is not part of the graph, but may be used to answer the question below. What is the measure of angle C? A. 92 B. 105 C. 120 D. 130 A business pays biweekly salaries of $20,000 every other Friday for a 10-day work period ending on that day. The adjusting entry necessary at the end of the fiscal period ending on the second Wednesday of the pay period includes a The center of a circle is located at (2, -1). A point on the circle is located at (-3,-1). What is the approximate circumference of the circle?A16 unitsB31 unitsC79 unitsD100 units