Write a C++ program that tests whether the array has four consecutive numbers with the same values. bool isConsecutive(int values[], int size) In the main() program you should prompt the user to enter a series of integers and display if the series contains four consecutive numbers with the same value. Your program should first prompt the user for the number of integers in the list or number of values in the series. Assume the maximum array size is 20. No global variables may be used Use a function prototype for said function The function can not do any cin or cout The main() function will do all the cin and cout You may assume the list contains positive integers only Sample runs (bolded text is output) : Enter the number of values: 6 Enter a value: 3 Enter a value: 4 Enter a value: 5 Enter a value: 5 Enter a value: 5 Enter a value: 5 The list has consecutive four numbers! Enter the number of values: 9 Enter a value: 3 Enter a value: 4 Enter a value: 5 Enter a value: 50 Enter a value: 5 Enter a value: 6 Enter a value: 5 Enter a value: 5 Enter a value: 6 The list has no consecutive fours numbers!

Answers

Answer 1

Answer:

#include <iostream>

using namespace std;

bool isConsecutive(int values[], int size){

   bool r = false;

   int count=0;

   for(int i=0;i<size;i++){

       if(values[i]==values[i+1]){

           count++;

           if(count==3)

           r=true;

       }

       else{

           count=0;

       }

   }

   return r;

}

int main() {

   // Write C++ code here

   int size;

   

   cout<<"enter the number of integer in list"<<endl;

   cin>>size;

   int arr[size];

   for(int i=0;i<size;i++){

       cout<<"enter the value of number"<<endl;

       cin>>arr[i];

   }

  bool result= isConsecutive(arr,size);

  if(result){

      cout<<"The list has consecutive fours numbers!"<<endl;

  }

  else{

      cout<<"The list has no consecutive fours numbers!"<<endl;

  }

   return 0;

}

Explanation:

Above program is written in C++ language.

All bold-faced words and letters are C++ keywords.


Related Questions

Write a function called no_you_pick. no_you_pick should have two parameters. The first parameter is a dictionary where the keys are restaurant names and the values are lists of attributes of those restaurants as strings, such as "vegetarian", "vegan", and "gluten-free".
#
#The second parameter is a list of strings representing of necessary attributes of the restaurant you select.
#
#Return a list of restaurants from the dictionary who each contain all the diet restrictions listed in the list, sorted alphabetically. If there are no restaurants that meet all the restrictions, return the string
#"Sorry, no restaurants meet your restrictions". Types of diet restrictions that exist in this question's universe are: vegetarian, vegan, kosher, gluten-free, dairy-free
#
#For example:
#grading_scale = {"blossom": ["vegetarian", "vegan", "kosher", "gluten-free", "dairy-free"], \
# "jacob's pickles": ["vegetarian", "gluten-free"], \
# "sweetgreen": ["vegetarian", "vegan", "gluten-free", "kosher"]}
#guests_diet = ["dairy-free"]
#no_you_pick(grading_scale, guests_diet) -> ["blossom"]


#Write your code here!
def no_you_pick(restaurants, preferred_diet):
result = []
for i in preferred_diet:
for key, value in restaurants.items():
# print(value)
if i in value:
result.append(key)
result.sort()
return result
return "Sorry, no restaurants meet your restrictions"

#Below are some lines of code that will test your function.
#You can change the value of the variable(s) to test your
#function with different inputs.
#
#If your function works correctly, this will originally
#print: blossom
grading_scale = {"blossom": ["vegetarian", "vegan", "kosher", "gluten-free", "dairy-free"], \
"jacob's pickles": ["vegetarian", "gluten-free"], \
"sweetgreen": ["vegetarian", "vegan", "gluten-free", "kosher"]}
guests_diet = ["dairy-free"]
print(no_you_pick(grading_scale, guests_diet))
**My code doesn't seem to work, any help with it I'll really appreciate it!**

Answers

Answer:

...

Explanation:

apply the fade transition with smoothly effect to all slides in the presentation​

Answers

Answer:

12

Explanation:

its very long answer so that it is that

What features do web development tools provide?

Web development tools come with several features to ease the process of building websites. Templates allow you to
experiment with a ___
Plug-ins allow you to___

Answers

The correct answer for the first choice is “variety of looks” and the other answer is “add features such as a payment system or spam blocker”
Explanation: platolivesmattertooyk?

Common uses of webinars include _____. Select all that apply.

A. corporate training

B. business meetings

C. distance learning

D. product demonstrations

Answers

Answer: distance learning

Explanation:

webinars are considered to be the best way that is currently used on a large scale to conduct online classes. it is referred to as the workshop, lecture, etc that conduct through the internet.  

it is defined as an interactive session that main aims to give, receive information in real-time. it consists of audio and video session between the listeners and speaker.

The common uses of the webinars incudes distance learning, corporate meetings, and product demonstration. Thus options B, C, and D are correct.

What is a webinar?

A webinar is an online event that is hosted by the organizations and companies and is broadcasted to the selected group of people by making the use of a computer and the internet.

These webinars can help in the launch of a product, can be useful for the distance learning purpose, and also help in business meetings.

Find out more information about the webinars.

brainly.com/question/20047596

This finding maximum number function will keep on going until we reach at the last value
[12, 18, 299, 38, 999, 89, 101, 500, 801, 45]

Answers

In which algorithm first the maximum element is found and then placed at the end?
Heapsort algorithm
The Heapsort algorithm involves preparing the list by first turning it into a max heap. The algorithm then repeatedly swaps the first value of the list with the last value, decreasing the range of values considered in the heap operation by one, and sifting the new first value into its position in the heap.

2. Write these functions definitions:
d) Function div2Numbers () that divides 2 integers.
Compile and test your function with the following main function:
int main()
1
char op;
cout<<"Enter + to add 2 integers\n";
cout<<"Enter - to subtract 2 integers\n";
cout<<"Enter x to multiply 2 integers\n";
cout<<"Enter / to divide 2 integers\n";
cout<<"Enter the operator required: ";
cin>>op;
switch (op)
{
case '+': add2 Numbers (); break;
case '-': sub2 Numbers (); break;
case 'x' : mul2 Numbers (); break;
case '/': div2 Numbers (); break;
default: cout<<"Invalid operator entered\n";
break;
}
a) Function add2 Numbers () that adds 2 integers.
b) Function sub2 Numbers () that subtracts 2 integers.
c) Function mul2Numbers () that multiplies 2 integers.​

Answers

Answer:

Complete the code with the following code segment:

void add2Numbers(){

   int num1, num2;

   cout<<"Enter any two numbers: ";

   cin>>num1>>num2;

   cout<<num1+num2;

}

void sub2Numbers(){

   int num1, num2;

   cout<<"Enter any two numbers: ";

   cin>>num1>>num2;

   cout<<num1-num2;

}

void mul2Numbers(){

   int num1, num2;

   cout<<"Enter any two numbers: ";

   cin>>num1>>num2;

   cout<<num1*num2;

}

void div2Numbers(){

   int num1, num2;

   cout<<"Enter any two numbers: ";

   cin>>num1>>num2;

if(num2==0){

cout<<"Division by 0 is invalid";

}else{

   cout<<(float)num1/num2;}

}

Explanation:

The function added to this solution are:

add2Numberssub2Numbersmul2Numbersdiv2Numbers

Each of the functions

declares two integers num1 and num2prompt user for inputsgets user inputs from the user

For add2Numbers() function:

This line adds the two integer numbers and prints the result

   cout<<num1+num2;

For sub2Numbers() function:

This line subtracts the two integer numbers and prints the result

   cout<<num1-num2;

For mul2Numbers() function:

This line multiplies the two integer numbers and prints the result

   cout<<num1*num2;

For div2Numbers() function:

This if condtion checks if the denominator is 0

if(num2==0){

If yes, the following is printed

cout<<"Division by 0 is invalid";

If otherwise, the division is calculated and the result is printed

   cout<<(float)num1/num2;

See attachment for complete program

In the program below, numA is a
def multiply(numA, numB):
product = numA* numB
return product
answer = multiply(8,2)
print (answer)

parameter

qualifier

accumulator

return value

Answers

Answer:

parameter

Explanation:

In the function 'multiply' you can pass values in that are to be used inside the function. These are called 'parameters' and are in parentheses after the function name.

- A qualifier is a name that adds extra information, such as 'final' to prevent reassignment

- An accumulator is a variable you use to sum up a bunch of values

- A return value is a mechanism to pass the result of a function back to the calling program (into 'answer' in above example).

What is your favorite game that you like to play ? ? ?

Answers

Answer:

Elder Scrolls online on xbox

Explanation:

Answer:

minecraft

Explanation:

Finish the sentence. If the IP address and MAC address are parameters of layer 3 and layer 2, respectively, a port number is a parameter of ______?

Answers

Answer:

Layer 4

Explanation:

MAC address works at the data link layer (layer 2) of the OSI model. Mac address allows computers to uniquely identify themselves in the network

IP Address is a logical address that works at the network layer of OSI model (layer 3) (actually the IP layer of TCP/IP model).

The port number works at the transport layer of the OSI model (layer 4).The port number uses sequence number to send segments to the correct application thereby ensuring they arrive in the correct order.

Anyone know how to do this?

Answers

Answer:

bro it is simple click on text and click between the lines and u can write easily.

hope u mark me brainliest thank u ♡♡♡

yea you basically fill it in with the information that will be provided on another page

hope this helps : )

brainliest plz

____ Is an Internet service that allows users to send and receive short text messages In real time.

Answers

Answer:

SMS is the answer to this problem

Please NEED HELP ASAP WILL MARK BRAINLIEST ONLY #8

Answers

Answer:

I think its A

Explanation:

Write a C++ function, smallestIndex, that takes as parameters an int array and its size and returns the index of the first occurrence of the smallest element in the array. To test your function, write a main that prompts a user for a list of 15 integers and outputs the index and value of the first occurrence of the smallest value.

Answers

Answer:

Explanation:

The code in C++ is written as:

#include <iostream>

using namespace std;

int smallestIndex(int arr[],int size)

{

int min=arr[0],ind=0;

for(int i=0;i<size;i++)

{

if(min>arr[i])

{

min=arr[i];

ind=i;              NOTE: ind serves as a variable that is holding the smallest

}                                   element index of array

 

}

return ind;

}

int main() {

int arr[15];

cout<<"Enter 15 integers: ";

for(int i=0;i<15;i++)

cin>>arr[i];

for(int i=0;i<15;i++)

cout<<arr[i]<<" "<<endl;

int index=smallestIndex(arr,15);

cout<<"The position of the first occurrence of the smallest element in list is: "<<index<<endl;

cout<<"The smallest element in list is: "<<arr[index];

}

OUTPUT:

Enter 15 integers:

4

5

8

4

6

1

2

1

4

5

7

9

5

7

8

4   5  8  4  6  1  2  1  4  5  7  9  5  7  8  

The position of the first occurrence for the smallest element in the list is 5

The smallest element in the list is: 1

The logical way tables are linked is known as the database…

A. Schema
B. Primary Key

Answers

Answer:

B Primary Key

Explanation:

I think it is Primary Key but you can just make sure


4. In a relational database, entities are defined by
O A. values.
O B. columns.
O C. attributes.
O D. rows.

Answers

Answer:

C. attributes

Explanation:

A relational database is a database system that stores information within its servers. It has rows and columns that contain the data stored in them and which can be accessed at any time with the right administrative privileges.

In a relational database, entities are defined by their attributes. This is because an entity is the data that needs to be stored so, the attribute specifies that information and gives its value.

Create a SELECT statement that returns the count, average, max and min of the invoices submitted by each vendor, who has submitted more than one invoice. Order by the number of invoices in descending order. Should return 12 rows.

Answers

Answer:

SELECT Count(order_invoice) as number_of_invoices, Max(order_invoice) as maximum_invoice, Min(order_invoice) as minimum_invoice, Avg(order_invoice) as average_invoice

FROM vendor JOIN invoice ON invoice.id = vendor.id

WHERE order_invoice > 1

ORDER BY number_of_invoices DESC

Explanation:

The select statement of the SQL or structured query language returns twelve rows of four columns from the inner join of the vendor and invoice table in a database where the order_invoice column in the invoice table is greater than one. The result of the query is ordered by the alias column "number_of_invoices" in descending order.

Users report that the network is down. As a help desk technician, you investigate and determine that a specific router is configured so that a routing loop exists. What should you do next

Answers

Answer:

Determine if escalation is needed.

Explanation:

Since in this case, it has been determined that a specific router is configured in a way that a routing loop exists, the technician would further need to determine if the following issues are persistent;

having a switching loop on the networkgeneral router problemsrouting loopif there are broadcast storms.

What is the default zoom percentage in Word?

50%
100%
150%
200%

Answers

Answer:

The default zoom percentage in Word is 100%.

Answer:

100

Explanation:

Implement a program called genes.py that does the following: a. Reads a DNA sequence t as command-line argument b. Reads strings (one by one) representing genes from standard input until EOF (use the functions stdio.isEmpty() and stdio.readString()), and for each string s i. Constructs a Gene object g from s ii. Writes g iii. Writes whether g contains the DNA sequence t or not c. Writes the percentage of genes that contain t, up to two decimal places

Answers

Answer:

Following are the code to this question:

import sys#import package sys

class Gene:#defining a class Gene

   gString = ""#defining a string variable

   def __init__(self, gString):#defining a constructor

       self.gString = gString#defining object to hold string value

gCount = 0#defining integer variable

mCount = 0#defining integer variable

t = input();#input value from user end

for s in sys.stdin:#defining for loop to check input value

   g = Gene(s)#defining g variable to pass value in class parameter

   gCount +=1#incrementing the value of gCount variable

   if(t in s):#defining if block to check input

       mCount +=1#incrementing the matchCount value

       print( g.gString,"True")#print value True

   else:#else block

       print( g.gString,"False")#print value False

   print("{:.2f}".format(mCount*100/gCount))#print percentage value

Output:

Please find attachment file.

Explanation:

In the code, a class Gene is declared, that defines a string variable geneString, and creates its constructor, and store the string variable value.

In the next step, a three-variable gCount, mCount, and t defined, in which variable "t" is used for an input value, and inside the for loop, it uses the conditional statement, that checks its value and increments the integer value, and print true or false as a message.

By dividing the control plane from the data plane, SDN offers the flexibility to view the entire data plane infrastructure as a ________ resource that can be configured and controlled by an upper layer control plane.

Answers

Answer:

Virtual

By dividing the control plane from the data plane, SDN offers the flexibility to view the entire data plane infrastructure as a Virtual resource that can be configured and controlled by an upper layer control plane.

Explanation:

The separating data plane (SDN) is used by users to hide the specifics of a device data layer so that all devices would be treated equally thereby representing the entire data plane as a  virtual abstract layer thus enhancing network efficiency.

The SDN work mainly on the Control and data plane separating both of the planes. Also, the SDN make networks more agile and flexible.

SDN provides the flexibility to view the entire data plane infrastructure as a

virtual resource that can be configured and controlled by an upper layer

control plane.

The type of resource which makes use of SDN to control an upper layer control plane is known as:

Virtual  

Based on the given question, we are asked to state the type of resource which makes use of SDN to control an upper layer control plane and how it is viewed for it it function effectively.

With this in mind, we can see that this can only be effectively done with a virtual resource so that the separating data plane can be effective in hiding the device data layer and test the other variables.

Read more about virtual resource here:

https://brainly.com/question/2680845

A desktop system on your network has been compromised. Despite loading different operating systems using different media on the same desktop, attackers appear to have access to that system every time it is powered up and placed on the network. This could be an example of what type of rootkit

Answers

Answer: Firmware rootkit

Explanation:

From the question, since despite loading different operating systems using different media on the same desktop, and the fact that attackers appear to have access to that system every time it is powered up and placed on the network. This could be an example of firmware rootkit

Firmware rootkits are a threat to ones online safety. In this scenario, the firmware of the computer are targeted by the rootkits and not the operating system and malware are then installed which can destroy the router, or hard drive. This can be used by hackers.

Draw the tree that results when you add the values 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 to each of the following initially empty trees Binary search tree 2-3 tree 2-4 tree Red-black tree

Answers

Answer:

What exactly are you asking?

Explanation:

Please don't report me, I'll edit my answer once I know the question

We see that the  black height of a node is the number of black nodes on the path from the node to the root of the tree.

What is a Binary search tree?

The B\\binary search tree is described as rooted binary tree data structure with the key of each internal node being greater than all the keys in the respective node's left subtree and less than the ones in its right subtree.

A unique variety of self-balancing binary search tree is the red-black tree has the  following characteristics:

Any node's left subtree is shorter than the node itself.Any node's right subtree is bigger than the node itself.Each and every node has the same black height.

Binary search tree for 2-3 tree: is shown below:

   10

  /  \

 20   40

/  \  / \

30  50 60  70

Binary search tree for 2-4 tree is shown below:

   30

  /  \

 20   50

 / \   / \

10  40 60  70

/ \  / \  / \

80 90 100

Binary search tree for Red-black tree:

   20(R)

  /  \

 /    \

10(B)    30(R)

 /  \   /  \

40(B)  60(B)  70(B)

/ \  / \  / \

80(B) 90(B) 100(B)

Learn more about Binary search tree  at:

https://brainly.com/question/30391092

#SPJ2

the processes of only seeing only some records frome data table is called as what​

Answers

Explanation:

For other uses, see Table. An example table rendered in a web browser using HTML. A table is an arrangement of data in rows and columns, or possibly in a more ... The first row is not . is called Html

Please need help ASAP will mark brainliest

Answers

Answer:

x8 negakation with a false

Write a public member function removeRandom that removes a random element from the ArrayBag. This method should also return a boolean indicating whether an element was actually removed

Answers

Answer:

Explanation:

The following code is written in Java. It is a function that takes in the ArrayList called ArrayBag as a parameter and randomly removes one of the elements in the ArrayList. As long as the ArrayBag has at least 1 element it will return true otherwise it will return false.

public static boolean removeRandom(ArrayList ArrayBag) {

               Random rand = new Random();

               

               if (ArrayBag.size() > 0) {

                       int randomNumber = rand.nextInt(ArrayBag.size());

                       ArrayBag.remove(randomNumber);

                       return true;

               } else {

                       return false;

               }

       }

what is a computer ?​

Answers

Answer:

A computer is a machine that can be instructed to carry out sequences of arithmetic or logical operations automatically via computer programming. Modern computers have the ability to follow generalized sets of operations, called programs. These programs enable computers to perform an extremely wide range of tasks.

Explanation:


Well.......

A computer is a machine that can be instructed to carry out sequences of arithmetic or logical operations automatically via computer programming. Modern computers have the ability to follow generalized sets of operations, called programs. These programs enable computers to perform an extraordinary wide range of tasks.










According to Wikipedia ;))

Create a method named replaceCastMember that allows the name of a castMember at an index in the castMembers array to be changed. The method should take in 2 arguments, the int index and the String castMemberName. The method should return a true if the replacement was successful, false otherwise. (Note: Only update the castMember in the array if the index is valid)

Answers

Answer:

Explanation:

The following code is written in Java. It is a method that takes in the two parameters as requested and checks whether or not the index exists in the array. If it does then it replaces the String in that Index with the new castMemberName String parameter that was given. If the replacement is successful then it returns a True boolean, if not then it returns a False boolean. The array being used must be named castNames and have a global scope to be accessible by the method since it is not passed as a parameter.

public static boolean replaceCastMember(int index, String castMemberName) {

               System.out.println(castNames.size());

               if (index <= castNames.size()) {

                       castNames.remove(index);

                       castNames.add(index, castMemberName);

                       return true;

               } else {

                       return false;

               }

       }

You're typing up a document and come across the word sentient. You don't believe the readers of the document will know the meaning of the word, and you would like to substitute another word that's more common. What Word feature would you use to assist you in selecting a different word?

Answers

You would use a software tool that looks up the synonyms such as The Thesaurus

You would use a software tool that looks up the synonyms such as The Thesaurus.

What are the application?

Applications are type of software that are installed in a specific operating system of a computer that deviates from those system software installed together with the system itself. These third-party applications are necessary for other functions such as entertainment, business, leisure and other needs addressing of which the system software can't provide.

A networking software can be defined as a set of executable instructions (codes) that is typically designed and developed to instruct a networking device on how to perform a specific task or transmit data from one location to another.

System software has software that has been intended to serve as the foundation for other software. The Operating systems like the macOS, Linux, Android, and the Microsoft Windows are the examples of the system software, as are computational science software, game engines, search engines, industrial automation, and software as a service applications.

Therefore, You would use a software tool that looks up the synonyms such as The Thesaurus.

Learn more about software on:

https://brainly.com/question/892475

#SPJ3

What is solar system​

Answers

Answer:

The sun together with the group of celestial bodies that are held by its attraction and revolve around it is called solar system.

Hope it helps :)

You are a network administrator for your company. A frantic user calls you one morning exclaiming that nothing is working. What should you do next in your troubleshooting strategy

Answers

Answer:

Explanation:

With these types of problems, you need to first try and Isolate the specific problem so that you can then come up with and apply a solution. Therefore, your next step should be to ask the client to explain what he is trying to do. Then ask him what he is doing and what is the first problem that he is running into. This will allow you to get a sense of what the client is trying to accomplish as well as his/her knowledge base on what they are doing in order to adapt your strategy accordingly.

Other Questions
Choose only one that the same vowel sound as pie.A. MayB. ClimbC. Hole what does x equal in 6x + 9 = -12 Large geographic region characterized by a distinct climate and mix of species Which statement about the behavior ofliving things is true? i need help plz be fast guys please, help, asap thank youu 7. Who built the first oil pipeline? Describe a time where you struggled to overcome an obstacle or had a problem dealing with another person. Make sure you identify the type of conflict.i give brainliest Veronica is shopping for school clothes. She wants to buy pants and shirts. The cost of her clothes can be found using the expressions 30x+ 25y where x is the number of pants and y is the number of shirts. She will also pay 8 tax. If Veronica buys eight shirts and two pairs of pants use the expression from question 4 to determine the total cost of the bill including 8% tax A student presses her palm by her thumb with a force of 75 N . What would be the pressure under her thumb having contact area is 1.5 cm2 Restaurant A sells 10 tacos for $8.50. How much does Restaurant A charge for 1 taco? A line passes through (10,5) and (13,-4). Write the equation of the line in standard form.A. 3x-y=5B. 3x-y=25C. 3x+y=25D. 3x+y=35 PLEASE HELP THANK YOU!! Solve for x:[tex]\frac{9}{x}= \frac{x}{16}[/tex]A.144B.12C.24D.18 9f + 4 - 7f = 8 pls help plzz anwser ill give brainlest simplify 16- 8/15 what is the value of the nearest hundredth d=7.09 6.48 how do u add really big fractions I need help A.S.A.P 100 points Distance in Feet1. Earlier this week the famous "Live Cannonball - Gunter Money was shot from a cannon at the Austin Expo.Gunter flew to a height of 70 feet and traveled a distance of 160 feet only to land perfectly in a safety net.Assume (0, 0) was the starting point for Gunter's flight and that he landed in the net at (160, 0).(a) Use matrices to find the equation for Gunter Money's path.(b) Write the equation for Gunter Money's path in vertex form.US 11:50acer