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
Any song recommendations, pls dont say 6ix9ine or lil pump
gogolik [260]

I actually do have one tho. Try Megan Tha Stallion.

8 0
3 years ago
Read 2 more answers
Consider the following class interfaces:
o-na [289]

Answer:

class teacher and student I didn't actually read it but I think it is class student

6 0
3 years ago
Which of the following is an example of a currency Number format in Excel?
Elena L [17]

$21.08 is an example of a currency Number format in Excel

<u>Explanation:</u>

For items like currency, one can format numbers in cells in Excel.

To view all possible number formats, click the Dialog Box Launcher attached to Number on the Home tab in the Number group.

In the Format Cells dialog box, in the Category list, click Currency or Accounting.

In the Symbol box, tick the currency symbol.

In the Decimal places box, insert the number of decimal places.

Employed for common financial values and presents the default currency figure with quantities.

Ctrl+Shift+$ is a shortcut to represent currency values.

8 0
3 years ago
What type of cable is used to connect a workstation serial port to a cisco router console port?
butalik [34]

a <span>Ethernet-<span>Cable is a how to put it together</span></span>

<span><span /></span>

6 0
3 years ago
Which type of partitioning is performed onRelation-X?
goldenfox [79]

Answer: B) Vertical Partitioning

Explanation:

As, vertical partitioning is performed on Relation X, it is used for dividing the relation X vertically in columns and it involves creation of tables and columns. They also use some additional tables to store left out columns. We cannot partition the column without perform any modification of value of the column. It only relies on keeping the particular attributes of relation X.

7 0
3 years ago
Other questions:
  • I damaged a k12 laptop. do I have to pay for the damage? and if so how much?
    5·1 answer
  • Microsoft acknowledged that if you type a res:// url (a microsoft-devised type of url) which is longer than ____ characters in i
    9·1 answer
  • # q7 - create function readFileFirstLast() to meet the conditions below
    10·1 answer
  • Which option is an example of a Boolean operator?<br> O A. HTML<br> O B. <br> C. SEO<br> D. NOT
    5·1 answer
  • Gina is upgrading your computer with a new processor. She installs the processor into your motherboard and adds the cooling syst
    7·1 answer
  • Many company websites are now designed to do more than just sell a product. These​ websites, known as​ __________ websites, atte
    14·1 answer
  • .... . .-.. .-.. --- .-.-.-<br><br><br> TRANSLATE THAT.
    10·1 answer
  • _______________ ________________ have human editors that evaluate, select, and organize websites into a hierarchy of categories.
    11·1 answer
  • there are 3 numbers X,Y,Z such that twice X is equal to therice Y and four times Y is equal to five times Z. the ratio between X
    6·1 answer
  • Why is it important to prepare the farm resources before you start working? explain​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!