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
zmey [24]
2 years ago
14

Write a program called array1.cpp file that use either regular for loop or range based for loop to display the contents of the a

rray test []. You can also write a function to display the contents of array. Submit your code array1.cpp to Blackboard.
Computers and Technology
1 answer:
ch4aika [34]2 years ago
7 0

Answer:

The program in C++ is as follows:

#include <iostream>

using namespace std;

void display(int array_test [], int n){

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

       cout<<array_test[i]<<" ";   }

}

int main(){

   int n;

   cin>>n;

   int array_test[n];

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

       cin>>array_test[i];

   }

   display(array_test,n);

   return 0;

}

Explanation:

This defines the display function

void display(int array_test [], int n){

This iterates through the array

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

This prints each element of the array

       cout<<array_test[i]<<" ";   }

}

The main begins here

int main(){

This declares n as integer; n represents the length of the array

   int n;

This gets input for n

   cin>>n;

This declares the array

   int array_test[n];

The following iteration gets input for the array

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

       cin>>array_test[i];

   }

This calls the display function to display the elements of the array

   display(array_test,n);

   return 0;

}

You might be interested in
Help it's the last question quickkk​
aniked [119]
I would say the answer is b, but ⟟ might be wrong
7 0
3 years ago
Given an array arr, of type int, along with two int variables i and j, write some code that swaps the values of arr[i] and arr[j
Inessa05 [86]

You'll need a helper variable for this, so depending on your programming language, the solution becomes:

int helper;

helper = arr[i];

arr[i] = arr[j];

arr[j] = helper;

3 0
2 years ago
A news website uses 32-bit integers to count the number of times an article has been viewed. The website is becoming more popula
Irina-Kira [14]

Answer:

2^32 times as many values can be represented

Explanation:

32-bit. This means that the number is represented by 32 separate one’s and zero’s. 32 bits of 2 possible states = 2^32=4,294,967,296 possible values.

Integer meaning that only whole multiples of one are accepted.

Signed meaning that negative values are accepted. This halves the number of possible positive values (roughly), so the largest number you can represent is 2^31–1=2,147,483,647, but instead of 0, the smallest number you can represent is -2,147,483,648. An unsigned 32-bit integer, by contrast, can represent anything from 0 to 4,294,967,295.

7 0
2 years ago
3.18: Pizza Pi Joe’s Pizza Palace needs a program to calculate the number of slices a pizza of any size can be divided into. The
alina1380 [7]

Answer:

#program in python.

#variables

slice_area=14.125

pi=3.14159

#read diameter

d=int(input("Enter diameter of pizza:"))

#area of pizza

area=pi*(d/2)*(d/2)

#number of slice

no_slice=int(area/slice_area)

#print slice

print("total silce are:",no_slice)

Explanation:

Declare and initialize a variable "slice_area" with 14.125 which is the area of a pizza slice.Initialize a variable "pi" with 3.14159.Then read the diameter of pizza.Find the area of pizza as "area=pi *d/2*d/2".Divide the total area with area of pizza slice.This will be the number of slice.

Output:

Enter diameter of pizza:20                                                                                                

total silce are: 22

6 0
3 years ago
When you enforce restrictions, what must you do immediately?
sweet [91]
The answer is A create a password
4 0
3 years ago
Read 2 more answers
Other questions:
  • List the steps that you need to locate Microsoft Word on your computer
    7·1 answer
  • 1) The program reads an integer, that must be changed to read a floating point. 2) You will need to move that number into a floa
    6·1 answer
  • In order to consolidate your theoretical knowledge into technique and skills with practical and applicational value, you will us
    8·1 answer
  • It is not possible to use keywords to search for themes. true or false.
    9·1 answer
  • How would you define data science ?
    10·1 answer
  • Research the topic of legal and ethical behaviors or dilemmas related to technology. Identify five topics of concern and briefly
    9·1 answer
  • Assume that you have an ArrayList variable named a containing 4 elements, and an object named element that is the correct type t
    9·1 answer
  • What is one effective way for employees to keep their skillsets current?
    8·2 answers
  • What is the definition of bug?​
    11·1 answer
  • Direction: using the data at the left, answer the questions that follows.​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!