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
Vanyuwa [196]
3 years ago
10

The integer variables first and last have been declared and assigned values (with last >= first). Allocate an integer array t

hat can hold the squares of the numbers between first and last (inclusively), assign the resulting pointer to the variable squares (which you must declare), and initialize the array to the squares of the numbers from first to last (in that order).
Computers and Technology
1 answer:
tester [92]3 years ago
5 0

Answer:

The following are the code in the C++ programming language.

//declare pointer type integer variable

int* squares;

//declare integer variable and initialize to 0

int s=0;

//set the for loop

for(int i=first; i<=last; i++)

{

//increment in the by 1

s++;

}

//initialize the incremented index value

squares=new int[s];

//set the for loop

for(int j=first; j<=last; j++)

{

squares[j-first]=j*j;

}

Explanation:

<u>The following are the description of the program</u>.

  • Firstly, declare the integer data type pointer variable 'squares' and declare the integer data type variable 's' and initialize in it to 0.
  • Set the for loop statement that iterates from the variable 'first' and ends at the variable 'last' then, every time the variable 's' is incremented by 1 when the loop iterates.
  • Then, pass the final incremented value in the index of the variable 'squares' and set the for loop that initializes the elements of the array.
You might be interested in
In which of the following cases is the application of a nested loop not justified? When comparing two lists of integers When for
Thepotemich [5.8K]
Hi my name is about that
4 0
3 years ago
Your friend is an intern at the local Department of Health and needs to prepare a report about the recent activity of the influe
Butoxors [25]

Answer:

#include<bits/stdc++.h>

using namespace std;

int main(){

  // Defining Variables

  int no_of_weeks;

  int total_cases = 0;

  //Declaring Vector of Pair of Integer and string

  std::vector<pair<int,string>> data;

  // Taking Input for the Number of Weeks

  cout<<"Enter No. of Weeks\n";

  cin >> no_of_weeks;

  // Running the Loop for no_of_weeks times

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

      int A,B,C;

      // Taking Input for different types of flus

      cout<<"Enter No. of Cases of Flu A, B, C for week" << i + 1 << " seperated by space : \n";

      cin >> A >> B >>C;

      // Adding all the cases in a week

      int cases_in_a_week = A + B + C;

      // Updating total cases

      total_cases += cases_in_a_week;

      // Declaring the level variable

      string level;

      // Updating the level of the week corresponding to each case

      if(cases_in_a_week < 500) level = "Low";

      else if(cases_in_a_week >= 500 && cases_in_a_week < 2000) level = "Moderate";

      else level = "Widespread";

      // Storing the Week's information by using a vector of pairs

      // in which pair's first is the number of cases which is of type int

      // while the second is the level of the flu which is of the type string

      data.push_back(make_pair(cases_in_a_week,level));

  }

  // Linking the stdoutput to the flu_report.txt file

  // this also creates the file with the same name if it doesn't exists

  freopen("flu_report.txt", "w", stdout);

  // Printing the respective output data with Bar Chart of stars for each level

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

      //printing the week no. and number of cases

      cout<<i+1<<" "<<data[i].first<<" "<<data[i].second<<" |";

      //calculating the number of stars

      int stars = data[i].first/250;

      //printing the stars of the bar chart

      for(int j = 0; j < stars ; j++) cout<<"*";

      cout<<endl;

  }

  //printing the total number of cases

  cout<<total_cases;

}

Explanation:

3 0
3 years ago
Read 2 more answers
Input an int between 0 and 100 and print the numbers between it and 100, including the number itself and the number 100. If the
Murrr4er [49]

import java.util.Scanner;

public class JavaApplication42 {

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       int count = 0;

       System.out.println("Enter an integer between 0 and 100");

       int num = scan.nextInt();

       if (num <= 0 || num >= 100){

           System.out.println("error");

       }

       else{

           while(num <= 100){

               if (count == 20){

                   System.out.println("");

                   count = 0;

               }

               else{

                   System.out.print(num+" ");

                   count++;

                   num++;

               }

           }

       }

   }

   

}

I hope this helps!

6 0
3 years ago
What types of storage can be used to access your data on another computer?
allochka39001 [22]
A USB drive is portable and can be used.
4 0
4 years ago
Read 2 more answers
List out the input and output device .​
Dmitry [639]

Computer - Input Devices

Keyboard.

Mouse.

Joy Stick.

Light pen.

Track Ball.

Scanner.

Graphic Tablet.

Microphone.

Computer - Output Devices

Monitor.

Printer.

Headphones.

Computer Speakers.

Projector.

GPS.

Sound Card.

Video Card.

5 0
3 years ago
Read 2 more answers
Other questions:
  • How do you train a computer to recognize your voice?
    14·2 answers
  • A call center company wants to implement a domain policy primarily for its shift workers. The call center has large groups with
    11·1 answer
  • Susan teaches many individuals and business professionals how, why, and the benefits and challenges to using social media. Of th
    15·1 answer
  • What is the general form of an internet email address<br>​
    5·1 answer
  • Package Newton’s method for approximating square roots (Case Study 3.6) in a function named newton. This function expects the in
    7·1 answer
  • _____ is a method of computing that delivers secure, private, and reliable computing experiences based on sound business practic
    7·1 answer
  • Who here has a crush on jk from bts but feels more mature than him
    10·2 answers
  • What information is contained in the title bar
    13·1 answer
  • Which of the following tabs on the Ribbon contains the command to add a Quick Part to a document? A Design B Insert C View D Hom
    7·1 answer
  • Write a recursive function called DigitCount() that takes a positive integer as a parameter and returns the number of digits in
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!