Home Work 1: Data Types, Variables and Expressions
#include <stdio.h>
main()
{
/* this program displays the result of subtraction
of one predefined values from the other */
int value1, value2, result;
value1 = 87;
value2 = 15;
result = value1 - value2;
printf("The result after subtracting %d from %d = %d \n",
value1, value2, result);
}
#include <stdio.h>
main()
{
/*this programs reads input thro the key
board and computes the average*/
float score1, score2, score3, score4;
float average;
scanf("%f %f %f %f", &score1,&score2,&score3,&score4);
average = (score1 + score2 + score3 + score4)/4;
/*to make sure that the average
does not get truncated, we have declared
the scores as float but not integers*/
printf("The average score of %5.2f %5.2f %5.2f %5.2f
is %5.2f\n", score1, score2, score3, score4, average);
}
Here is the formula:
c = ((10.45 + (6.686*sqrt(v))-(o.447*v))/
22.034*(t-91.4))+91.4
Here the function ``sqrt'' computes the square root. Write a C program
to accept values for velocity and temperature to calculate the wind
chill, c and print ``given the temperature ``t
F,'' and the wind
velocity ``v,'' the wind chill is ....
#include <stdio.h>
#include <math.h>
main()
{
/*program to compute wind chill for a
given wind velocity and temperature*/
float v, t, c;
scanf("%f %f",&v,&t);
if ((v >= 5 && v <= 90) && (t >= -40 && t <= 90))
{
c = ((10.45 + (6.686*sqrt(v))- (0.447*v))/22.034*(t-91.4))+91.4;
printf("given the temperature %f 0F,
and the wind velocity %f,
the wind chill is %f", v, t, c);
}
}
This document was generated using the LaTeX2HTML translator Version 96.1 (Feb 5, 1996) Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
The command line arguments were:
latex2html -split 0 -html_version 3.0 hw1-sol.tex.
The translation was initiated by Vijay & on Thu Mar 5 10:21:52 EST 1998