ASSIGNMENT 1 SEMM 1013
EXERCISE 1
A C program contains the following declarations and initial assignments:
int i=8, j=5;
float x=0.005, y=-0.01;
char d=d;
Complete the program in order to evaluate and display the value of the following expressions:
a)x + yf)-(i+j)
b)i % j + 2g)2*((i/5)+(4*(j-3))%(i+j-2))
c)j + i * xh)j + (int)(x)
d)(j + i) * xi)d
e)j / ij)++d
EXERCISE 2
A C program contains the following declarations and initial assignments:
int i=8, j=5;
float x=0.005, y=-0.01;
Complete the program in order to evaluate and display the value of the following expressions:
a)abs(i-2*j)e)sqrt(x*x + y*y)
b)fabs(x+y)f)log(x)
c)ceil(x+y)g)pow(x-y,3.0)
d)floor(x)h)sin(x-y)
EXERCISE 3
A C program contains the following declarations statements:
int a, b;
float x, y;
Complete the program so that the value of 12 can be entered into the computer and assign to a, -8 assigned to b, 0.011 assigned to x, and -2.2 x 106 to y.The program should also display the value of the variables using appropriate format.
EXERCISE 4
Write a complete C program to accomplish the following tasks:
a)Generate the message
Please enter the radius of a sphere:
Then the radius of the sphere is to be entered on the same line.
b)Calculate the volume and area of the sphere.
c)Display the value of the volume and area of the sphere using appropriate format.
Test the program using the following values for the radius: 1, 6, 12.2, 0.2.
EXERCISE 5
Write a complete C program to convert a temperature reading in degrees Fahrenheit to degrees Celsius, using the formula
C = (5/9) x (F-32)
Test the program with the following values: 68, 150, 212, 0, -22, -200 (degrees Fahrenheit).
Reviews
There are no reviews yet.