Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Place Values

by CodeChum Admin

Manipulating values from a series of numbers is fun, but let's try exploring the use of loops a little more.


How about printing out each digit of a number starting from its rightmost digit, going to its leftmost digit?


Instructions:

  1. Input a non-zero positive integer.
  2. Using while loop, print out each digit of the inputted integer in separate lines, starting from its rightmost digit until the leftmost digit of the number.
  3. Tip #1: Use % 10 to get the rightmost digit. For example, if you do 412 % 10, then the result would be the rightmost digit, which is 2.
  4. Tip #2: On the other hand, use / 10 to remove the rightmost digit. For example, if you do 412 / 10, then the result would be 41.
  5. Tip #3: You'd have to repeat Tip #1 and Tip #2 inside the while() loop for this problem while the inputted integer is not yet 0.

Input

A line containing an integer.

214

Output

Multiple lines containing an integer.

4
1
2





Against All "Odds"

by CodeChum Admin


Looping numbers is fun, but it's even more exciting when we combine complex tasks to it, just like looping through a series of numbers and performing a series of code only to special numbers, like odd ones! And today, we're going to do just that.

Are you ready?


Instructions:

  1. Input a positive integer. This will serve as the starting point of the loop.
  2. Using a while() loop, print out all the odd numbers starting from the inputted integer, until 0. The outputted numbers must all be separated by line.
  3. Also remember that since the loop goes to descending order, a decrement variable shall be created and decreased per iteration for the loop to terminate when it reaches 0.

Input

A line containing an integer.

10

Output

Multiple lines containing an integer.

9
7
5
3
1





Write a fruitful function sum_to(n) that returns the sum of all integer numbers up to and

including n. So sum_to(10) would be 1+2+3. . . +10 which would return the value 55.


I want very simple code because I am a student.


Write a program that reads a string and returns a table of the letters of the alphabet in

alphabetical order which occur in the string together with the number of times each letter

occurs. Case should be ignored. A sample output of the program when the user enters the data

“ThiS is String with Upper and lower case Letters”, would look this this:

a 2

c 1

d 1

e 5

g 1

h 2

I 4

l 2

n 2

o 1

p 2

r 4

s 5

t 5

u 1

w 2


I want a very simple code for students.



The great circle distance is the distance between two points on the surface of a sphere.



Let (x1, y1) and (x2, y2) be the geographical latitude and longitude of two points.



The great circle distance between the two points can be computed using the following formula:


d = radius * arccos(sin(x1) * sin(x2) + cos(x1) * cos(x2) * cos(y1 - y2))



Write a program that prompts the user to enter the latitude and longitude of two points on the earth in degrees and displays its great circle distance.



The average earth radius is 6,371.01 km.


The angles as given in the formula are all in degrees.



Use negative values


for south and east degrees, positive values for north and west degrees.



Do all you can to make your program structure when running, conform with the sample run given below:



Enter point 1 (latitude and longitude) in degrees:


39.55, -116.25



Enter point 2 (latitude and longitude) in degrees:


41.5, 87.37



The distance between the two points is 10691.79183231593 km

You can use Cramer’s rule to solve the following 2 x 2 system of linear equations: Ax+By=E


Cx+Dy=f


X=ED-Bf/AD-Bc


Y= Af-Ec/AD-Bc



Write a program that prompts the user to enter A, B, C, D, E, and F nd display the


result. If AD – BC is 0, report that “The equation has no solution”.



Do all you can to make your program structure when running, conform with the sample runs


given below:



Enter a, b, c, d, e, f: 9.0, 4.0, 3.0, -5.0, -6.0, -21.0


x is -2.0 and y is 3.0



Enter a, b, c, d, e, f: 1.0, 2.0, 2.0, 4.0, 4.0, 5.0


The equation has no solution

(Geometry: area of a pentagon) Write a program that prompts the user to enter the

length from the center of a pentagon to a vertex and computes the area of the pen-

tagon, as shown in the following figure.

                               3V3

    The formula for computing the area of a pentagon is Area =

                               2

                                  where s is

    the length of a side. The side can be computed using the formula s = 2r sin

    where r is the length from the center of a pentagon to a vertex. Here is a sample

    run:

    Enter the length from the center to a vertex: 5.5

    The area of the pentagon is 108.61

                                JEnter


(Physics: find runway length) Given an airplane's acceleration a and take-of

speed v, you can compute the minimum runway length needed for an airplane to

take off using the following formula:

                 length

                      2a

  Write a program that prompts the user to enter v in meters/second (m/s) and the

acceleration a in meters/second squared (m/s), and displays the minimum runway

length. Here is a sample run:

Enter speed and acceleration: 60, 3.5 LEnter

The minimum runway length for this airplane is 514.286 meters


(Sum the digits in an integer) Write a program that reads an integer between 0 and

1000 and adds all the digits in the integer. For example, if an integer is 932, the

sum of all its digits is 14. (Hint: Use the % operator to extract digits, and use the //

operator to remove the extracted digit. For instance, 932 % 10 = 2 and 932 //

10 = 93.) Here is a sample run:

Enter a number between 0 and 1000: 999 Enter

The sum of the digits is 27


(Average speed) Assume a runner runs 14 kılometers in 45 minutes and 30 sec-

onds. Write a program that displays the average speed in miles per hour. (Note that

 1 mile is 1.6 kilometers.)


LATEST TUTORIALS
APPROVED BY CLIENTS