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
lesantik [10]
3 years ago
13

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
2 answers:
lilavasa [31]3 years ago
8 0

Answer:

This program is written in C++. The explanation of code is given below in explanation section.

Explanation:

#include <algorithm>

#include <functional>

#include <iostream>

#include <vector>

using namespace std;

//function to check vector element is even or not  

bool IsEven(int n) {

   return (n % 2) == 0;

}

//function to check vector element is odd or not

bool IsOdd(int n)

{

   if (n%2!=0)// detection of odd value

   {

       return 1;

   }

}

bool IsVectorEven(vector<int> vect)// check even number in vector

{

   auto countEven = count_if(vect.begin(), vect.end(), IsEven);//count total even numbers in vector

   int size= vect.size();//count total number in vector/check vector size  

   

   if(countEven==size)//all counted even number to size of vector

   {  

       cout<<"\nAll even";//display the message

       //return 1;

   }

   else

   {

       cout<<"\nnot even or odd";//else display the message

      // return 0;

   }

}

bool IsVectorOdd(vector<int> vect)//check odd vector

{

   auto countOdd = count_if(vect.begin(), vect.end(), IsOdd);// count total odd number in vector

   int size= vect.size();// count total number in vector

   

   if(countOdd==size)// if vector size is equal to vector counted odd number

   {  

       cout<<"\nAll odd";// then vector has all odd number/elements

       //return 1;

   }

   else

   {

       cout<<"\nnot even or odd";//else has odd and even numbers

       //return 0;

   }

}

int main()

{

   vector<int> vec{ 4, 2, 4, 6, 8, 10};//declaration of a vector

   

   IsVectorEven(vec);//check even number in vector  

   IsVectorOdd(vec);//check odd number in vector.  

   

   

   

   

   

}

                                           

____ [38]3 years ago
4 0

Answer:

integers=[]

while True:

      number=int(input())

      if number<0:

       break

      integers.append(number)  

print("",min(integers))

print("",max(integers))

Explanation:

You might be interested in
Have you ever had an incorrect perception about someone else?
Soloha48 [4]
Yes, all the time. Sometimes, it's feeling based. You get a bad vibe from someone, and you tend to go without without really giving said person a chance. Sometimes those vibes are helpful, sometimes it's you overreacting from bad experiences. (: hope all is well!
7 0
4 years ago
What laws are broken when you hack someone?
postnew [5]

Answer:

it depends

Explanation:

if you are hacking for a purpose that is benefiting the person being hacked, that is ethical hacking. ethical hacking is not illegal, as long as you get permission from the person being hacked.

if you hack someone without their knowledge, that is unethical hacking, and that is in many cases, a crime, and if it has enough of a detrimental effect on a companys process, it could land you into prison and earn you a hefty fine.

ethical hacking is good for testing a networks security, and if all is well, the ethical hacker shouldnt be able to get into a network if it is secured properly.

6 0
3 years ago
1. What are the biggest risks when using the public Internet as a Wide Area Network (WAN) or transport for remote access to your
enyata [817]

Answer:

The problems or risk when using a WiFi is that, hackers often have the ability to position themselves between the user and the end point connection. and once these hackers gains access to your information and privacy, u might lose important documents or contents.

It is of utmost importance that when an end user is using a public WiFi as a WAN, he/she must ensure to browse with VPN turned on, and the sharing options turned off.

Explanation:

Solution

One of the biggest risk with public WiFi is the ability or capacity for hackers to position themselves between you (user) and the point of connection. so instead of communicating directly with the hotpot, at several times you end up sending your information to the hacker.

The hacker also have access or privileges to every information you send out such as credit card information, emails and so on. once the hacker gains access to that information, you run into trouble.

As an end user when making use of public WiFi to ensure to browse with VPN (Virtual private Network) on and turned off sharing options

4 0
3 years ago
Which language do you use to add functionality to a web page
Dovator [93]
The answer is Javascript. In partner with HTML/HTML5 (Hypertext markup language : which provides the structure and CSS (Client Side Scripting : Provides the design to the structure). JS or Javascript programming language provides the function at the backend of a webpage. It responds to the input and also calls on the PHP / SQL Scripts to tap the database.
6 0
3 years ago
What are the constraints of mine shaft head gear​
Serhud [2]

Answer:

Mine headgear constructions support wheel mechanisms for suspending winding cables that transport workers and ore up and down deep level shafts. These strange anthropomorphic structures have become the iconic symbol for mining.

4 0
3 years ago
Other questions:
  • Please I need all the help I can get Thank You So Much
    14·1 answer
  • The _______________ database structure is considered one of the key technologies of a new generation of Web-based applications.
    7·1 answer
  • I NEED IT NOWW
    13·2 answers
  • Why is it important to recognize web adress endings ?
    13·1 answer
  • Create a Quadrilateral, Oval, Triangle, Polygon class that are all extended from an abstract Shape class (given below). Then ext
    14·1 answer
  • Write the header file Stadium.h for a Stadium class. The Stadium class has the following data members: 1) an array of 1000 Seat
    7·1 answer
  • Based on the details in The Riddle of the Rosetta Stone, how did the career of Jean-Baptiste Fourier differ from that of Jacques
    9·2 answers
  • Please help it’s timed
    11·1 answer
  • The sequence of Figures shows a pattern. if the pattern repeats, how many triangles will the figure 5 have ?​
    7·1 answer
  • output device. Vrite very short answer of the following questions. What is computer hardware? Which dovico in lini nwhich device
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!