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
Asked Jun 25, 2019
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

Expert Answer

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

Check out a sample Q&A here.

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

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: write a program in c++. You work for a box company, and have been asked to write a program to compar...

A: Solution:The C++ program has the following algorithm:Declare and initialize the required variables.D...

question_answer

Q: Code should be in C++ Absolute Value Template: Write a function template that accepts an argument an...

A: Since Function Templates are used to handle all possible data types you can say generic data type at...

question_answer

Q: You are not required to execute the queries. However, your syntax must by accurate.You must give at ...

A: Hey, since there are multiple sub-part questions posted, we will answer first three questions. If yo...

question_answer

Q: how can I write a statement in C++ that would print last name, followed by a comma, followed by firs...

A: Given below is the C++ program to print a statement with last name, followed by comma, followed by f...

question_answer

Q: What’s the difference between integer, Floating point, and integer variable length? And how do I cal...

A: Assuming you are working in C language the explanation for the two data types integer and floating p...

question_answer

Q: example:"apple-&gt;orange-&gt;banana-&gt;pear"-&gt;NULLreturn "orange"Thanks!

A: ApproachIn the function longest(), we'll declare an integer named highestLength and assign 0 to it.N...

question_answer

Q: For this program you need to use Eclipse. Carefully read the instructions and write a program that r...

A: Program plan:Class name: EmpPayrollImport the required header files.Define the class "EmpPayroll"Def...

question_answer

Q: Find dfa’s that accept the following languages: (a) L (aa∗ + aba∗b∗). (b) L (ab (a + ab)∗ (a + aa)).

A: We will solve part (a) L (aa∗ + aba∗b∗) first. To get the DFA, we need to draw the NFA of the given ...

question_answer

Q: Not very familiar with RAID so I would really appreciate some help and an explanation behind the ans...

A: RAID is an acronym for Redundant Array of Independent Disk. It is a process of storing the data into...