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
muminat
4 years ago
6

Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp

= {90, 92, 94, 95}, print: 90, 92, 94, 95 Your code's output should end with the last element, without a subsequent comma, space, or newline.
Computers and Technology
1 answer:
vlabodo [156]4 years ago
4 0

Answer:

#include <iostream>

using namespace std;

int main() {

   int NUM_VALS;//variable NUM_VALS for the size of the array..

   cout<<"Enter the size of the array"<<endl;

   cin>>NUM_VALS;//taking input the size of the array..

   int hourlyTemp[NUM_VALS]; //declaring array hourlyTemp of size n..

   cout<<"Enter values of the array "<<endl;

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

   cin>>hourlyTemp[i];//taking input of hourlyTemp

   for(int i=0;i<NUM_VALS;i++) //for loop for iterating over the array..

   {

       if(i!=NUM_VALS-1)

       cout<<hourlyTemp[i]<<", ";// print statement.

       else

       cout<<hourlyTemp[i];//print statement.

   }

return 0;

}

Explanation:

I have taken NUM_VALS variable for the size of the array hourlyTemp. First i am taking input the size of array form user and after that array elements are also entered by the user.I am iterating over the array using for loop and checking that it is not the last element if it is simply printing it if it is not then printing comma and space also.

You might be interested in
Write a function called prod_all that takes any number of arguments and returns their sum. Test the function by using these two
sattari [20]

Answer:

from functools import reduce

def prod_all(*args):

   prod = reduce(lambda x,y: x *y, args)

   return prod

result = prod_all(4,6,8)

print(result)

Explanation:

The use of the "*args" passes a tuple of variable length to a python defined function. The function above takes any number of arguments and returns the product using the python reduce module and the lambda function.

3 0
3 years ago
QlVEQkNjQWdERnpsSnJnVkJIMDVSbWtDK2ttZ1RSQzNEejJESkNhT20raEhqTWR3UFNINnVpaGk3YjhW
Misha Larkins [42]
Sure, it says "Hulk smash on keyboard"
8 0
3 years ago
over their whole lifetime about how much can someone with a professional degree expect to earn compared to someone with a highsc
Gemiola [76]

Really depends on the job most college based technology jobs pay about 100k 76k after taxes. Mechanics could range above that. Without a college degree most people don't make it above 30k. Thats not what i know for sure just of what i've seen.

4 0
4 years ago
In this lab, you create a programmer-defined class and then use it in a C++ program. The program should create two Rectangle obj
MakcuM [25]

The program based on the information given is illustrated below.

<h3>What is a program?</h3>

A computer program simply means a sequence of instructions in a programming language that is created for a computer to execute.

It should be noted that computer programs are among the component of software.

The program to create two rectangle objects and get their area and perimeter is depicted:

// Rectangle.cpp

using namespace std;

class Rectangle

{

public:

// Declare public methods here

void setLength(double);

void setWidth(double);

double getLength();

double getWidth();

double calculateArea();

double calculatePerimeter();

private:

// Create length and width here

double length, width;

};

void Rectangle::setLength(double len)

{

length = len;

}

void Rectangle::setWidth(double wid)

{

// write setWidth here

width = wid;

}

double Rectangle::getLength()

{

// write getLength here

return length;

}

double Rectangle::getWidth()

{

// write getWidth here

return width;

}

double Rectangle::calculateArea()

{

// write calculateArea here

return length*width;

}

double Rectangle::calculatePerimeter()

{

// write calculatePerimeter here

return 2*(length+width);

}

// This program uses the programmer-defined Rectangle class.

#include "Rectangle.cpp"

#include <iostream>

using namespace std;

int main()

{

Rectangle rectangle1;

Rectangle rectangle2;

rectangle1.setLength(10.0);

rectangle1.setWidth(5.0);

rectangle2.setLength(7.0);

rectangle2.setWidth(3.0);

cout << "Perimeter of rectangle1 is " << rectangle1.calculatePerimeter() << endl;

cout << "Area of rectangle1 is " << rectangle1.calculateArea() << endl;

cout << "Perimeter of rectangle2 is " << rectangle2.calculatePerimeter() << endl;

cout << "Area of rectangle2 is " << rectangle2.calculateArea() << endl;

return 0;

}

/*

output:

The perimeter of rectangle1 is 30

The area of rectangle1 is 50

The Perimeter of rectangle2 is 20

The area of rectangle2 is 21

*/

Learn more about program on:

brainly.com/question/1538272

#SPJ1

8 0
2 years ago
The device-aspect-ratio feature supported by Hypertext Markup Language (HTML) and Cascading Style Sheets (CSS) gives the ratio o
iogann1982 [59]

Answer:

True.

Explanation:

The aspect-ratio function is stated as a value < ratio > tag that representing the viewport aspect ratio of thickness to length. It is a range function, implying the lowercase minimum-aspect-ratio and maximum-aspect-ratio versions can also be used to request the lowest and highest amounts, accordingly.

so, the following scenario is true.

7 0
3 years ago
Other questions:
  • Create a set of use cases for the following health club membership system:
    13·1 answer
  • What are the 3 parts of a browser window? What componets are in each?
    5·1 answer
  • What is the best java 3d modeler library?
    7·1 answer
  • ________ take computers with wireless connections through an area and search for unprotected wireless networks, and then monitor
    13·1 answer
  • How does the View tab of the ribbon allow you to look at a document?
    9·1 answer
  • ) Using newline command : endl
    6·1 answer
  • Which line of code will cause the loop to execute exactly one time?
    13·1 answer
  • Que elementos han impactado las computadoras en la sociedad?​
    12·2 answers
  • Ventaja que implica usar funciones en las hojas de calculo
    12·1 answer
  • Select the correct answer.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!