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
Y_Kistochka [10]
2 years ago
7

Write a program that reads in a temperature value in °F. Create a function ConvertFahrenheit that takes that value as a paramete

r and prints out the equivalent values in °C and K. Note: Only the conversion and printing is done inside the function. Reading user input happens in main().
Computers and Technology
1 answer:
larisa86 [58]2 years ago
8 0

Answer:

#include<stdio.h>

void ConvertFahrenheit(float);

void main()

{

float fahrenheit_temp;

printf("Input the temperature in Fahrenheit: ");

 

scanf("%f", &fahrenheit_temp);

 

ConvertFahrenheit(fahrenheit_temp);

}

void ConvertFahrenheit(float fahren) {

float c, k;

 

c = (fahren - 32)/1.8;

k = (fahren + 459.67)/1.8;    

 

printf("Celsius = %f\n", c);

printf("Kelvin = %f", k);

}

Explanation:

  • Inside the main function, take the temperature in Fahrenheit as an input from user and call the ConvertFahrenheit function by passing it the  fahrenheit_temp variable as an argument.
  • Create the ConvertFahrenheit function for the conversion  and convert the fahrenheit value to the Celsius and Kelvin by using their conversion formulas respectively.
  • Lastly, display the result in Celsius and Kelvin.
You might be interested in
Write a (one) program for your microcontroller so that it:
AleksandrR [38]

Answer:

see explaination

Explanation:

1.) Each time the main program execution starts at address 0000 - Reset Vector. The address 0004 is “reserved” for the “interrupt service routine” (ISR).

ORG 0x000 ; processor reset vector

goto main ; go to beginning of main program

ORG 0x004 ; interrupt vector location

movwf w_temp ; save off current W register contents

movf STATUS,w ; move status register into W register

movwf status_temp ; save off contents of STATUS register

.

.

RETFIE

main

3.) Push button switch is connected to the first bit of PORT B (RB0) which is configured as an input pin. When the switch is pressed this pin RB0 will be grounded. The LED is connected to the first bit of PORT B (RA0)

4.) Push button switch is connected to the first bit of PORT B (RB0) which is configured as an input pin. When the switch is pressed this pin RB0 will be grounded. The LED is connected to the first bit of PORT B (RA0)

5.) Push button switch is connected to the first bit of PORT B (RB0) which is configured as an input pin. When the switch is pressed this pin RB0 will be grounded. The LED is connected to the first bit of PORT B (RA0)

#include <stdio.h>

#include <stdlib.h>

#define _XTAL_FREQ 800000//Declare internal OSC Freq as 8MHz

#include <xc.h>

#include<pic.h>

CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_OFF & MCLRE_ON & BOREN_OFF & LVP_OFF & CPD_OFF & WRT_OFF & CCPMX_RB0 & CP_OFF);

CONFIG(FCMEN_ON & IESO_ON);

unsigned int count=0;

main()

{

TRISA=0;//Sets all ports on A to be outputs

TRISB=1;//Sets all ports on B to be inputs

for(;;){

if(PORTBbits.RB0==1){//When the button is pressed the LED is off

PORTAbits.RA1 =0;

count=count+1;

}

else {

PORTAbits.RA1=1;

count = count +1;

}

if (count > 6){//if count =6 i.e 6 times button presses the RED LED turns on

PORTAbits.RA0=1;

}

else{

PORTAbits.RA0=0;

}

}

}

#include <stdio.h>

#include <stdlib.h>

#define _XTAL_FREQ 800000//Declare internal OSC Freq as 8MHz

#include <xc.h>

#include<pic.h>

CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_OFF & MCLRE_ON & BOREN_OFF & LVP_OFF & CPD_OFF & WRT_OFF & CCPMX_RB0 & CP_OFF);

CONFIG(FCMEN_ON & IESO_ON);

unsigned int count=0;

main()

{

TRISA=0;//Sets all ports on A to be outputs

TRISB=1;//Sets all ports on B to be inputs

for(;;){

if(PORTBbits.RB0==1){//When the button is pressed the LED is off

PORTAbits.RA1 =0;

count=count+1;

}

else {

PORTAbits.RA1=1;

count = count +1;

}

if (count > 8){//if count =8 i.e 8 times button presses the RED LED turns on

PORTAbits.RA0=1;

}

else{

PORTAbits.RA0=0;

}

}

}

#include <stdio.h>

#include <stdlib.h>

#define _XTAL_FREQ 800000//Declare internal OSC Freq as 8MHz

#include <xc.h>

#include<pic.h>

CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_OFF & MCLRE_ON & BOREN_OFF & LVP_OFF & CPD_OFF & WRT_OFF & CCPMX_RB0 & CP_OFF);

CONFIG(FCMEN_ON & IESO_ON);

unsigned int count=0;

main()

{

TRISA=0;//Sets all ports on A to be outputs

TRISB=1;//Sets all ports on B to be inputs

for(;;){

if(PORTBbits.RB0==1){//When the button is pressed the LED is off

PORTAbits.RA1 =0;

count=count+1;

}

else {

PORTAbits.RA1=1;

count = count +1;

}

if (count > 10){//if count =10 i.e 10 times button presses the RED LED turns on

PORTAbits.RA0=1;

}

else{

PORTAbits.RA0=0;

}

}

}

6 0
3 years ago
Jamey did a lot of research on his paper topic but can't figure out where to start writing. He has a loose plan in mind, but it'
Lisa [10]
He should come up with a definite plan.
5 0
2 years ago
Read 2 more answers
Which of the following transferable skills are generally the most look for in the it <br> field
kherson [118]

Answer:

mechanical, encryptions, communication, network admin, leadership, and teambuilding

Explanation:

6 0
2 years ago
What is Identity Theft?
olga55 [171]
A is correct! We did this in Law!

Have a merry Christmas!
5 0
3 years ago
Recall the insertion-sort-like algorithm in Problem 4 from Homework 2, where you know that certain pairs of contiguous items in
amid [387]

Answer:

See the attached picture.

Explanation:

See the attached picture.

7 0
3 years ago
Other questions:
  • 3 Points
    9·2 answers
  • Swiping up with three fingers on mac os x launches what?
    8·1 answer
  • Which IEEE standards define Wi-Fi technology?
    10·1 answer
  • You work in the Accounting department and have been using a network drive to post Excel workbook files to your file server as yo
    15·1 answer
  • What are the two most popular applications of theInternet?
    7·1 answer
  • What is adobe photoshop?
    10·2 answers
  • JUST NEED TO KNOW WHO ALL DOSE EDGINUITY
    12·2 answers
  • In a three-tier architecture, the component that runs the program code and enforces the business processes is the:_______.
    11·1 answer
  • Is there a way for me to play a .mp3 file from my computer using Atom?
    10·1 answer
  • to provide for ecmascript compatibility in older browsers, you can use group of answer choices javascript shivs javascript shims
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!