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
goblinko [34]
3 years ago
13

Assume that the array monthSales of integers has already been declared and that its elements contain sales data for the 12 month

s of the year in order (i.e., January, February, etc.). Write a statement that writes to standard output the element corresponding to October. Do not write anything else out to standard output.
Computers and Technology
1 answer:
bonufazy [111]3 years ago
6 0

Answer:

The c++ statement to display the sale corresponding to the month of October is given below.

cout << monthSales[9];

Explanation:

The integer array monthSales contains data for 12 months beginning from January to December, in the order in which the months appear.

January sales is represented by index 0 while December sales is given by index 11.

Hence, the index of the array is one less than the numerical value of the month.

The sales value corresponding to October, the tenth month, is given by index 9, monthSales[9].  

Only the sales for October is displayed as per the question. Nothing else is displayed.

The c++ program to implement the above statement is given below.

#include <iostream>

using namespace std;

int main() {

   // array containing sales data for 12 months

   int monthSales[12];

monthSales[12] = { 1234, 2345, 3456, 4567, 5678, 6789, 7890, 8901, 9012, 1208, 1357, 2470 };

       // only sales data corresponding to month of October is displayed  

   // nothing else is displayed

   cout << monthSales[9];

return 0;    

}

OUTPUT

1208

First, the array is declared.

   int monthSales[12];

The keyword int represents the integer data type of the array.

The number 12 indicates the length of the array. The array will contain 12 values.

The index of the last element will be 12 – 1 = 11.

This is followed by initialization with twelve numerical values.

monthSales[12] = { 1234, 2345, 3456, 4567, 5678, 6789, 7890, 8901, 9012, 1208, 1357, 2470 };

Only the value for October needs to be displayed. This is achieved by the below statement.

   cout << monthSales[9];

The cout keyword is used to display to the standard output.  

No new line character is inserted. No message is displayed.

The sales data can be modified. Only integer values should be taken. Floating or double values will not compile and an error will be displayed.

You might be interested in
C++
daser333 [38]

#include<iostream>

#include <fstream>

#include <vector>

#include <string>

#include "StatePair.h"

using namespace std;

int main() {

ifstream inFS;

int zip;

int population;

string abbrev;

string state;

unsigned int i;

vector<StatePair <int, string>> zipCodeState;

vector<StatePair<string, string>> abbrevState;

vector<StatePair<string, int>> statePopulation;

inFS.open("zip_code_state.txt");

if (!inFS.is_open()) {

    cout << "Could not open file zip_code_state.txt." << endl;

    return 1;

}

while (!inFS.eof()) {

    StatePair <int, string> temp;

    inFS >> zip;

    if (!inFS.fail()) {

        temp.SetKey(zip);

    }

    inFS >> abbrev;

    if (!inFS.fail()) {

        temp.SetValue(abbrev);

    }

    zipCodeState.push_back(temp);

}

inFS.close();

inFS.open("abbreviation_state.txt");

if (!inFS.is_open()) {

    cout << "Could not open file abbreviation_state.txt." << endl;

    return 1;

}

while (!inFS.eof()) {

    StatePair <string, string> temp;

    inFS >> abbrev;

    if (!inFS.fail()) {

        temp.SetKey(abbrev);

    }

    getline(inFS, state);

    getline(inFS, state);

    state = state.substr(0, state.size()-1);

    if (!inFS.fail()) {

        temp.SetValue(state);

    }

    abbrevState.push_back(temp);

}

inFS.close();

inFS.open("state_population.txt");

if (!inFS.is_open()) {

    cout << "Could not open file state_population.txt." << endl;

    return 1;

}

while (!inFS.eof()) {

    StatePair <string, int> temp;

    getline(inFS, state);

    state = state.substr(0, state.size()-1);

    if (!inFS.fail()) {

        temp.SetKey(state);

    }

    inFS >> population;

    if (!inFS.fail()) {

        temp.SetValue(population);

    }

    getline(inFS, state);

    statePopulation.push_back(temp);

}

inFS.close();

cin >> zip;

for (i = 0; i < zipCodeState.size(); ++i) {

 }

for (i = 0; i < abbrevState.size(); ++i) {

 }

for (i = 0; i < statePopulation.size(); ++i) {

}

}

Statepair.h

#ifndef STATEPAIR

#define STATEPAIR

#include <iostream>

using namespace std;

template<typename T1, typename T2>

class StatePair {

private:

T1 key;

T2 value;

public:

StatePair()

{}

void SetKey(T1 key)

{

this->key = key;

}

void SetValue(T2 value)

{

this->value = value;

}

T1 GetKey() { return key;}

T2 GetValue() { return value;}

void PrintInfo()

{

cout<<key<<" : "<<value<<endl;

}

};

3 0
2 years ago
Who developed the first triage-like system for Napoleon's ar
Snowcat [4.5K]
Baron Dominique-Jean Larrey
4 0
3 years ago
Elena is used to kissing her friends on both cheeks as a form of greeting in her native country. She notices that her new friend
Veseljchak [2.6K]

Answer:

c. Norms.

Explanation:

When Elena noticed her friend getting uncomfortable when she kisses him on the cheeks as a form of greeting she was violating his norms.

Norms are something that is standard or typical.

In USA there they not used to kiss on the cheeks to greet their friends there would be some other norm of greeting someone.

5 0
3 years ago
Object-oriented systems have three general types of cohesion: _____, _____, and _____. A. method, class, inheritance B. method,
Verdich [7]

Answer:

D. method, class, generalization/specialization

Explanation:

The Cohesion is said to be the level to what an element of a module is related to others. Generally, the cohesion can be understood as an internal adhesive that holds together the modules. If the software is good then it is going to have high cohesion. Method and class are type of cohesion, as they hold the modules together. And generalization/specialization also is a general type of cohesion as generalization tracks the common features among the class, and binds them into one superclass. However, the specialization means creating subclasses out of the classes, and which is the meaning of the specialization. In an ideal situation, there should be high cohesion or single responsibility. However, in the case of inheritance, there can be multiple responsibilities. And hence composition like a generalization, specialization, association, aggregation are used to make use of the composition for reuse rather than inheritance. Have you seen language supporting multiple inheritances. You will never see it though there is some way. And its never allowed to ensure high cohesion. And hence three general types of cohesion are method, class and generalization/specialization. And this is option D.

4 0
3 years ago
Computer security experts devote their time and energy to the protection of sensitive data and the prevention of an outside atta
Alik [6]

Answer:

Information security policy are used for the prevention of intruders hacking a network when an organization start getting IT related attacks.

Explanation:

Information security policy are used for the prevention of intruders hacking a network when an organization start getting IT related attacks.

An information security policy are set of rules/policies designed to guide employees for the protection of the security of company information and IT systems. The reasons for these policies are:

  1. It defines what is required from organization’s employees for the security of the IT systems
  2. Information security policies provide a means to secure the organization against external and internal threats
  3. Information security policies are a mechanism to for ensuring an organization’s legal and ethical responsibilities
  4. Information security policies are created to hold each employee responsible with regard to information security
4 0
3 years ago
Other questions:
  • F we are reduced to a set of computer algorithms, how do we differentiate ourselves from our programming or our connectome? is i
    8·1 answer
  • The most popular way for hackers to take over hosts today is ________.
    15·2 answers
  • Insurance can help you:
    12·1 answer
  • Exploring Arraylists. Remember that arraylists are good for adding and removing things, and that they are clock-cycle friendlier
    13·1 answer
  • (a) Convert to hexadecimal: 1457.1110. Round to two digits past the hexadecimal point.
    8·1 answer
  • Which one of the following items is an example of software?
    5·1 answer
  • What is the missing line of code?
    10·2 answers
  • What is the difference between skew and rotate in the MS Paint application?
    14·2 answers
  • Old systems can be useful when designing new computer software.<br> True or False
    7·2 answers
  • How many levels of heading tags are allowed in html?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!