# 1) Create a array of Fahrenheit temperatures, as followsint fahr []= {0,1,2,3,4,5,6,7,8,9,10,32,33,34,35,36,37,38,39,40};2) create a function convert(int fahr) that converts Fahr to Cels, such as you did in class, outside of main(), above it.3) create a loop, that prints side by side Fahrenheit temperatures from the array above (in a similar way how you printed an array in class) and Celsius temperature by calling function convert(...) in the loop to get a matching Celsius temperature for each Fahrenheit temperature that you print.Do you program in C++ compiler online. Compile it step by step, making sure your code does not have syntax errors as you add new contents.

Question
46 views

1) Create a array of Fahrenheit temperatures, as follows

int fahr []= {0,1,2,3,4,5,6,7,8,9,10,32,33,34,35,36,37,38,39,40};

2) create a function convert(int fahr) that converts Fahr to Cels, such as you did in class, outside of main(), above it.

3) create a loop, that prints side by side Fahrenheit temperatures from the array above (in a similar way how you printed an array in class) and Celsius temperature by calling function convert(...) in the loop to get a matching Celsius temperature for each Fahrenheit temperature that you print.

Do you program in C++ compiler online. Compile it step by step, making sure your code does not have syntax errors as you add new contents.

check_circle

star
star
star
star
star
1 Rating
Step 1

Program Instructions:

• Define the given array in code and calculate the size of the array.
• Use for loop to print the Fahrenheit temperature and to call the convert() function o print the Celsius temperature.
• In convert() function, define a variable cels which will store the Celsius temperature.
• Convert the Fahrenheit temperature into Celsius temperature using the formula: cels = (fahr - 32) * 5/9.
• Finally, return the Celsius temperature to print it in the main() function.
Step 2

Program:

#include<iostream>

using namespace std;

// function to convert Fahrenheit temperatures into Celsius temperature

float convert(int fahr){

// use int for int values

float cels;

// formula for conversion

cels = (float(fahr) - 32) * 5/9;

return cels;

}

int main(){

// given array

int fahr []= {0,1,2,3,4,5,6,7,8,9,10,32,33,34,35,36,37,38,39,40};

...

### Want to see the full answer?

See Solution

#### Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

### Computer Science 