Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write c assignment statements for the following operations, using appropriate va

ID: 3870097 • Letter: W

Question

Write c assignment statements for the following operations, using appropriate valid identifiers:


1) Conversion of degrees Fahrenheit into degrees Celsius


2) Conversion of degrees Fahrenheit into degrees Rankine


3) Conversion of degrees Celsius into Kelvins


4) Conversion of height from feet and inches into centimeters (hint, use separate variables for feet


and inches)


5) Conversion of weight from pounds into newtons


6) Calculation of mass in kilograms from the weight in newtons, assuming a gravitational


acceleration of 9.807 m/s2


Write c printf statements that do the following:


7) A statement that asks the user to input their height in feet and inches, separating the two


numbers by a space. Display an example as follows:


(For example, if you are 6’2”, type “6 2” at the prompt.)


8) A series of statements that produce a table that shows temperature in different units, similar to


the following:


Temp (DegF) | Temp (DegC) | Temp (DegR) |Temp (K)


-------------+-------------+-------------+----------


(value) | (value) | (value) | (value)


Write c scanf statements that do the following:


9) A statement that takes two integers and stores them each in separate variables


10) A statement that takes a double and stores it in a variable


11) A statement that takes 3 characters and stores them each in separate variables


Explanation / Answer

#include<stdio.h>
#include<stdlib.h>
int main()
{
float C , F , R , K;
//statements for the conversion of fahrenheit to celcius
printf("Enter fahrenheit value ");
scanf("%f",&F);
C=(F-32)*(5.0/9.0);//use 5.0 and 9.0 as float to get correct results
printf("celcius is %f ",C);
  
//statements for Conversion of degrees Fahrenheit into degrees Rankine
printf("Enter fahrenheit value ");
scanf("%f",&F);
R=F+459.67;
printf("Rankin is %f ",R);
  
//statements for Conversion of degrees Celsius into Kelvins
printf("Enter Celcius value ");
scanf("%f",&C);
K=C+273.16;
printf("Kelvins is %f ",K);
  
//statements for Conversion of height from feet and inches into centimeters using separate variables
float feet , inches , cms;
printf("Enter feet value ");
scanf("%f",&feet);
cms=feet*30.48;
printf("cms of feet is %f ",cms);
  
  
printf("Enter inches value ");
scanf("%f",&inches);
cms=inches*2.54;
printf("cms of inches is %f ",cms);
  
//statements for Conversion of weight from pounds into newtons
float pounds , newton;
printf("Enter pounds value ");
scanf("%f",&pounds);
newton=pounds*4.44822;
printf("weight in newtons is %f ",newton);
  
// Calculation of mass in kilograms from the weight in newtons, assuming a gravitational acceleration of 9.807 m/s2
float g=9.807;
float kgs=newton/g;
printf("The weight in kgs is %f ",kgs);
  
//A statement that asks the user to input their height in feet and inches, separating the two numbers by a space. Display an example as follows
int f , i ;
printf("Enter height ");
scanf("%d%d",&f,&i);
printf("Height is %d %d ",f,i);
  
//statements to print the required table
printf("Temp (DegF) | Temp (DegC) | Temp (DegR) |Temp (K) ");

printf("-------------+-------------+-------------+-------- ");

printf(" (value) | (value) | (value) | (value) ");
  
//A statement that takes two integers and stores them each in separate variables
int a , b;
printf("Enter two integers ");
scanf("%d%d",&a,&b);//stored both of the variables in a and b respectively
printf("Stored values are %d %d ",a,b);
  
//A statement that takes a double and stores it in a variable
double c;
printf("Enter a double value ");
scanf("%lf",&c);//stored double in c
printf("Stored values is %lf ",c);
  
//A statement that takes 3 characters and stores them each in separate variables
char ch1 , ch2 , ch3 ;
printf("Enter 3 characters ");
scanf("%c",&ch1);
scanf("%c",&ch2);
scanf("%c",&ch3);
//stored these three characters in ch1 , ch2 and ch3 respectively
printf("Stored values are %c %c %c ",ch1,ch2,ch3);
//take care of whitespace because whitespace is also a character
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote