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
Ou have just set up a network that will use the tcp/ip protocol, and you want client computers to obtain ip configuration automa
Aleks [24]
DHCP (Dynamic Host Configuration Protocol)
5 0
3 years ago
Which character goes at the end of a line of code that starts with if?
weqwewe [10]

Answer:

Explanation:

tttttttttttt

4 0
3 years ago
The company called ____ offers a complete graphic information system software solution for computer-generated maps that stores a
jeyben [28]
The answer is <span>ESRI.  It </span>offers a complete graphic information system software solution for computer-generated maps that stores all its data in your oracle 10g database.  It stands for Environmental Systems Research Institute.  Esri's<span> GIS mapping software is the most powerful mapping and spatial data analytics technology available.</span>
7 0
3 years ago
When you select the data range for a pie chart, you should be sure to include the total cell on the worksheet?
Daniel [21]
This is not a question...
5 0
3 years ago
Which of the following functions of Information Security Management seeks to dictate certain behavior within the organization th
Dmitriy789 [7]

Answer:

The correct answer to the following question will be Option B (Policy).

Explanation:

  • The Policy is a systematic set of rules for driving policies and obtaining rational results. It is a declaration of intent and is applied as a process or protocol.
  • Policies are usually implemented by the governing body throughout the corporation.
  • It was the feature of Information assurance management, which sought to dictate those activities throughout the organization via a collection of institutional requirements.

Therefore, Option B is the right answer.

7 0
3 years ago
Other questions:
  • Suppose the program counter (pc) is set to 0x2000 0000. is it possible to use the jump (j) mips assembly instruction to set the
    15·1 answer
  • Pascal's Triangle is a triangular array in which every number represents the
    15·1 answer
  • Which computer device is used to capture or copy a photograph to place in a report?
    14·1 answer
  • A recursive method may call other methods, including calling itself. A recursive method has:
    7·1 answer
  • Difrent between computer and computer system​
    9·1 answer
  • What happens when a string doesn’t include the separator that’s specified in the parameter of the split() method?
    13·1 answer
  • Is the most important characteristic of a hard drive.​
    7·2 answers
  • Which are examples of basic text structures? Check all that apply.
    8·2 answers
  • In a relational database, information is organized into tables in which each row represents a(n ) ________. Group of answer choi
    6·1 answer
  • Due TODAY!!! Can someone please help me!!!
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!