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
This is an example of ______________ of variables:
Sedbober [7]

Answer:

Encapsulation is an example of variables

6 0
3 years ago
Create a flowchart that assigns a counselor to a student.
Nataly [62]
Please Help! Unit 6: Lesson 1 - Coding Activity 2
Instructions: Hemachandra numbers (more commonly known as Fibonacci numbers) are found by starting with two numbers then finding the next number by adding the previous two numbers together. The most common starting numbers are 0 and 1 giving the numbers 0, 1, 1, 2, 3, 5...
The main method from this class contains code which is intended to fill an array of length 10 with these Hemachandra numbers, then print the value of the number in the array at the index entered by the user. For example if the user inputs 3 then the program should output 2, while if the user inputs 6 then the program should output 8. Debug this code so it works as intended.

The Code Given:

import java.util.Scanner;

public class U6_L1_Activity_Two{
public static void main(String[] args){
int[h] = new int[10];
0 = h[0];
1 = h[1];
h[2] = h[0] + h[1];
h[3] = h[1] + h[2];
h[4] = h[2] + h[3];
h[5] = h[3] + h[4];
h[6] = h[4] + h[5];
h[7] = h[5] + h[6];
h[8] = h[6] + h[7]
h[9] = h[7] + h[8];
h[10] = h[8] + h[9];
Scanner scan = new Scanner(System.in);
int i = scan.nextInt();
if (i >= 0 && i < 10)
System.out.println(h(i));
}
}
4 0
2 years ago
Read 2 more answers
write a pseudo code that will allow a user to enter a number and divide that number by eleven and take the the modules of the en
emmasim [6.3K]

Answer:

sdhuvbfuisg

Explanation:

4 0
3 years ago
The _____ approach treats process and data independently and is a sequential approach that requires completing the analysis befo
Solnce55 [7]

Answer:

C. Object Oriented

Explanation:

In Object Oriented approach to development of information systems, processes and data are handled independently and could be tested as separate modules before the actual development begin.

Hope this helps!

4 0
3 years ago
A formula =A1+B2 is in cell D8. If you copy that formula to cell D9, what is the new formula in cell D9? A. '=A1+B2 B. '=A2+B3 C
Georgia [21]
It has to be B. Im sure of it.
6 0
3 years ago
Read 2 more answers
Other questions:
  • Which of these is NOT a sign that someone might be drunk
    11·2 answers
  • During which part of geologic time were dinosaurs most common?
    11·2 answers
  • Select the correct answer.
    15·1 answer
  • Write a function called factor that determines for a pair of integers whether the second integer is a factor of the first. The f
    11·1 answer
  • John is runnig his Database application on a single server with 24 Gigabytes of memory and 4 processors. The system is running s
    6·1 answer
  • Cloud suites are stored on your hard drive and are available anywhere you can access the Internet
    15·1 answer
  • What other options are there besides jail for 16 year old that commit a crime?
    8·2 answers
  • A source mainly provides <br> from a text or piece of media.
    6·2 answers
  • Importance of computer education​
    9·1 answer
  • any one that owns a chrome book there is a new update there is new features and there is a game on settings where you see what y
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!