Create a program that will convert the input inch(es) into its equivalent centimeters. One inch is equivalent to 2.54cms. Then display the result.
You are required to confirm the equation by a
simulation. In this simulation, you will consider how the ball moves
in very short time interval Δt.
I. You will assume that Δt is a constant double with a
value of 0.01. You can get the updated position using s = s + v * Δt. The velocity changes constantly—in
fact, it is reduced by the gravitational force of the earth. In a short time interval, Δv = –gΔt, you must
keep the velocity updated as v = v - g * Δt; In the next iteration, the new velocity is used to update the
distance.
You need to run the simulation until the cannon ball falls back to the ground. Your program should take
the initial velocity as an input. Update the position and velocity 100 times per second, but print out the
position only every full second. Also, printout the values from the exact formula s = vi t – (1/2) gt2
for the
comparison. Lastly plot the path that cannon ball will take to get the bonus marks.
Write a program that calculates the occupancy rate for a hotel. The program should start by asking the
user how many floors the hotel has. A for loop should then iterate once for each floor. In each iteration,
the loop should ask the user for the number of rooms on the floor and how many of them are occupied.
After all the iterations, the program should display how many rooms the hotel has, how many of them
are occupied, how many are unoccupied, and the percentage of rooms that are occupied. The
percentage may be calculated by dividing the number of rooms occupied by the number of rooms.
Input Validation: Do not accept a value less than 1 for the number of floors. Do not accept a number
less than 10 for the number of rooms on a floor.
Write a program to plot a graph of function f(x) = x
n + xn-1
. Your program should take a maximum
absolute value of x as well as a positive integer n as input. You will plot a graph for the range [0, x]. You
should label the y-axis according to the maximum value of x.
Implement a calculator using bitwise operators and for loops only. Your program should run correctly
for positive integers only. You calculator should be able to perform following operations.
Basic arithmetic functions (Addition, subtraction, division and multiplication); Square – to compute the
square of the given value and Power – to compute the power of an integer. It should take two int
arguments number and its power.
Using properties of a Maclaurin series
or Taylor series, you can approximate the function cos(x) using the following
formula:
cos(x) ≈ ∑ (−1)
n
x
2n
(2n)!
a
n=0
= 1 −
x
2
2!
+
x
4
4!
−
x
6
6!
+
x
8
8!
− . . . ..
x
2a
2a!
Write your own approximation of cos(x) without using any library methods (such as pow( ) etc.). Your
program should take x (in radians) and an as input. You should make two functions calcTerm( ) and
sumTerms( ) to calculate the value of cos(x). calcTerm( ) function will compute nth term in the sequence.
It should take x and term number as arguments and the return value of the term. sumTerms( ) takes a
single argument term value and should be used to calculate the sum of all terms. Finally, your program
will have a function testFunction( ), you will call it from main to verify whether your function is working
correctly or not.
write a program that takes string as an input and return the product of all individual digit present in string ,return 0
2. Mr. Raju want to read 10 array elements and wants to display them in the reverse way. Write a C
program to help Mr. Raju to display the array elements in the reverse way
Write the definition of a class Counter containing:
An instance variable named counter of type int
An instance variable named limit of type int.
A constructor that takes two int arguments and assigns the first one to counter and the second one to limit
A method named increment. It does not take parameters or return a value; if the instance variable counter is less than limit, increment just adds one to the instance variable counter.
A method named decrement. It also does not take parameters or return a value; if counter is greater than zero, it just subtracts one from the counter.
A method named get_value that returns the value of the instance variable counter.
Create a flowchart that let the user guess the secret number. Display "higher" if the number entered by the user is higher that the secret number, otherwise, display "lower". Display "correct" if the user correctly guessed the secret number and terminate the program