Question
Q1. int a, b, c; b=10; a=b; c= b; i. What does each of the above statements do ? ii. What are the values of
Q1.
int a, b, c;
b=10;
a=b;
c= b;
i. What does each of the above statements do ?
ii. What are the values of a and c at the end of above code segment ? What is the
difference due to ? What is the difference between statements 3 and 4 in the above code
segment ?
Q2. Write a C program that returns the stopping time and distance given initial velocity and rate
of deceleration. Your program should prompt the user to enter floating point values for initial
velocity (u) and rate of deceleration (a). Then it calculates the stopping time t as
t = u/a. The stopping distance (s) as s = (u
2
)/(2*a)
Q3. Write a C program to calculate and display the coordinates of midpoint - M of a line
segment between two given points - say A and B, the slope of the line - s and the distance b/w
the points A and B given by d. Your program should prompt the user to enter floating point
values for x and y coordinates for the two points - A (x1, y1) and B (x2, y2). Then it calculates
the floating point coordinates of the midpoint - M (xm, ym) using the formula -
Xm = (x1+x2)/2
ym = (y1+y2)/2
It calculates the slope s = (y2-y1)/(x2-x1)
It calculates distance using the formula d = sqrt ((x2-x1)
2
+ (y2-y1)
2
) (Hint- You will need to
include math.h, check online on sqrt function usage, it is simple and clear)
Then display the values of xm, ym, d and s correct upto two places of decimal.
Q4. a.Write a C program that accepts the value of an angle (xd) in degrees from the user (It
should prompt the user to keep 0 <= xd <= 360).
b. Then it should calculate the angle value in radians xr = (xd* PI)/180. Use PI = 3.1415. Print
the value correct upto two places of decimal.
c. Then calculate the value of sin (xr) using the built-in sin function of C (Hint- You will need to
include math.h, check online on sin function usage, it is simple and clear). Print the value.
d. Then calculate the value of sin (xr) by evaluating the expansion for sin i.e.
sin (x) = x - ((x
3
)/6) + ((x
5
)/120).
Print this calculated value
e. Calculate the difference b/w the value returned by C function and calculated using expression
evaluation. Print the error.
Use C in all the Questions. Thanks.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started