1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
PilotLPTM [1.2K]
3 years ago
10

On a piano, a key has a frequency, say f0. Each higher key (black or white) has a frequency of f0 * rn, where n is the distance

(number of keys) from that key, and r is 2(1/12). Given an initial key frequency, output that frequency and the next 4 higher key frequencies. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print('%0.2f %0.2f %0.2f %0.2f %0.2f' % (your_value1, your_value2, your_value3, your_value4, your_value5))
Computers and Technology
1 answer:
Stels [109]3 years ago
3 0

Answer:

#include <stdio.h>

int main()

{

float your_value1, your_value2, your_value3, your_value4, your_value5;

printf("Enter a frequency: ");

scanf_s("%f", &your_value1);//storing initial key frequency in your value 1

 

float r = 2.0 / 12;//typing 2.0 so it is treated as float and not int

your_value2 = your_value1 * r * 1; //initial*r*n

your_value3 = your_value1 * r * 2; //initial*r*n

your_value4 = your_value1 * r * 3; //initial*r*n

your_value5 = your_value1 * r * 4; //initial*r*n

printf("%0.2f %0.2f %0.2f %0.2f %0.2f", your_value1, your_value2, your_value3, your_value4, your_value5);

return 0;

}

Explanation:

The purpose of this exercise is to make you understand the difference between float and int. float variables are used when you need decimals in your calculations. int is used when you need integers. The problem in this exercise was the formulation of r. Now r is = 2/12, this means that when we type r as that, the computer assumes that it is an integer and treats it as such. So, it will convert the 0.166667 into 0. To overcome this, all you have to do is type 2.0 instead of 2 alone.

The %0.2 command restricts the float variable to 2 decimal places. By default, it has 6 decimal places.

I have used the function scanf_s instead of scanf simply because my compiler does not work with scanf.

You might be interested in
Then create a new Java application called "StringSlicer" (without the quotation marks) that uses methods to:
anyanavicka [17]

Answer:

See the explanation section

Explanation:

import java.util.*;

//The above statement is to import the Scanner and ArrayList class

public class StringSlicer {

   public static void main(String args[]) {

   Scanner scan = new Scanner(System.in);

   System.out.println("Enter your string: ");

   String inputString = scan.nextLine();

   

   ArrayList<Character> stringList = new ArrayList<Character>();

   for(int i = 0; i < inputString.length(); i++){

           stringList.add(inputString.charAt(i));

       }

       

   for(Character letter: stringList){

           System.out.println(letter);

       }

   }

}

5 0
4 years ago
A hard drive that is running slowly may not have been properly?
Effectus [21]
Its probably out dated our its been over used.
7 0
3 years ago
_____ is a valid URL, or internet address. In this URL, ______ indicates the protocol.
Natalija [7]

Answer:

1. B.http://www.example.com

2. A. http

Explanation:

7 0
3 years ago
Explain how communication promotes cooperation and industrial peace​
tensa zangetsu [6.8K]

Explanation:

Communication helps the management to know what the organisation wants and how it can be performed. Through effective way of communication it promotes the industrial peace and good relations. 7. ... It enables the management to take managerial decisions which depends upon the quality of communication.

4 0
3 years ago
The _____ can be used to paste text in any order.
PolarNik [594]

The answer is Clipboard

The Clipboard in Microsoft Office products stores text copied or cut from anywhere and allows you to paste the stored items into the current or another Office document. This tool can allow you to copy items and paste them the way you want in the document.

3 0
4 years ago
Read 2 more answers
Other questions:
  • The ________ file system supports a maximum file size of 2gb
    12·1 answer
  • When executing System.out.println(a2), the toString() method in the Object class is invoked. The program cannot be compiled, bec
    11·1 answer
  • Which description of the plain text file format is most accurate?
    10·1 answer
  • Which of the following is the 1's complement of 10?
    10·2 answers
  • */ What's wrong with this program? /* public MyProgram { public static void main(String[] args); } int a, b, c \\ Three integers
    12·1 answer
  • One side in a Transmission Control Protocol (TCP) connection has not been able to properly recover from a series of malformed se
    6·1 answer
  • A device that connects to a network without the use of cables is said to be?​
    13·1 answer
  • Question 3
    13·1 answer
  • Cost, time, knowledge are examples of
    9·1 answer
  • Can computers be opened from the All programs submenu
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!