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
Marina CMI [18]
1 year ago
5

9.18 lab: even/odd values in a vector write a program that reads a list of integers, and outputs whether the list contains all e

ven numbers, odd numbers, or neither. the input begins with an integer indicating the number of integers that follow. 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. isvectoreven returns true if all integers in the array are even and false otherwise. isvectorodd returns true if all integers in the array are odd and false otherwise. bool isvectoreven(vector myvec) bool isvectorodd(vector myvec)
Computers and Technology
1 answer:
lana66690 [7]1 year ago
6 0

def is_list_even(my_list):

   for i in my_list:

       if(i%2 != 0):

           return False

   

   return True

   

   

def is_list_odd(my_list):

   for i in my_list:

       if(i%2 == 0):

           return False

   

   return True

   

def main():

   n = int(input())

   lst = []

   

   for i in range(n):

       lst.append(int(input()))

   

   if(is_list_even(lst)):

       print('all even')

   

   elif(is_list_odd(lst)):

       print('all odd')

   

   else:

       print('not even or odd')

       

       

if __name__ == '__main__':

   main()

You might be interested in
Complete two examples of how scientists, technologists, engineers, and mathematicians may work together to create a new product
asambeis [7]

Answer:

By thinking of ways to create environment friendly products such as biodegradable water bottles

3 0
2 years ago
Sharing a workbook helps to complete on time. Multiple people accessing the workbook help to build
BlackZzzverrR [31]
Collaboration skills
7 0
3 years ago
True or False:<br><br> You can convert your PowerPoint presentation in web pages.
jenyasd209 [6]

Answer:

true

Explanation:

4 0
3 years ago
Read 2 more answers
To select more than one sketched entity, you need to press and hold down the ________ key on the keyboard while selecting the en
almond37 [142]

Answer:

The answer to this question is Control(ctrl).

Explanation:

We use control(ctrl) key when we need to select multiple entities.

So when we want to select more than one sketched entity we need to press and hold the control key on the keyboard when we are selecting the items.

Hence we conclude that the answer to this question is Control(ctrl).

6 0
3 years ago
Write the statement that includes a friend function named before in the class dateType that takes as parameters two objects of t
Lerok [7]

Answer:

In opp friend function is a function that gives the same access to private and protected data. It is declared in class that is granting access.

Explanation:

#include<iostream.h>

using namespace std;

class Sum

{

 int a, b, add;

 public:

 void input()  

{

 cout << "Enter the value of l and m:";

 cin >> l>>m;     taking input from users

}

 friend void add(sum &t);

 void display()  

{

  cout << "The sum is :" << z;

}

};

 void add(sum & p)  

{

  p.add = p.a + p.b;

}

 int main()  

{

  sum p1;

  p1.input();

  add(p1);

  p1.display();

  return false;  

if(display==5)  

{

 return true;  //true is returned if sum is equal to 5

}

else        //if they are not the same

{

 return false;

}

}

8 0
3 years ago
Other questions:
  • Abigail is interested in connecting her tablet that usually connects to a wireless network, to her personal computer that usuall
    11·2 answers
  • Assume you have just started a new job, have a car loan, and have a student loan. You have just received a cash gift of $1,000 f
    14·1 answer
  • When naming a file you should use the _____________ instead of a space in a filename.
    6·1 answer
  • The instant pivot button is displayed in the statistics and visualization tabs when a _______ search is run.
    15·1 answer
  • which telecommunications service allows internet and telephone service to work over the same phone line
    13·1 answer
  • Which of the following is not a web browser? A. safari B. explorer C. chrome D. google​
    12·2 answers
  • Use JavaWrite a program that will simulate a change machine found at cash registers. Input the amount due and amount paid from t
    12·1 answer
  • All portions, to include subject, title, paragraphs, sub-paragraphs, graphics, tables, charts, and bullet statements, must be pr
    12·1 answer
  • Which branch of science helps avoid or minimize stress-related injuries at workplace?
    14·1 answer
  • When entering numbers that start with a zero, apply the _____ number format.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!