Question

NOTE: ALL C PROGRAMS MUST BE DONE IN UNIX SYSTEM WITH VI EDITOR 1. Write a...

NOTE: ALL C PROGRAMS MUST BE DONE IN UNIX SYSTEM WITH VI EDITOR

1. Write a program that asks the user to enter a U.S. dollar amount and then shows how to pay that amount using the smallest number of $20, $10, $5 and $1 bills. Save the file as

dollarAmountToNotesFirstinitialLastname.c

Sample output:

Enter a dollar amount: 93

$20 bills: 4

$10 bills: 1

$5 bills: 0

$1 bills: 3

Hint: Divide the amount by 20 to determine the number of $20 bills needed, and then reduce the amount by the total value of the $20 bills. Repeat for the other bill sizes. Be sure to use integer values throughout, not floating-point numbers.

2. Write the following C program: celsius2fahrenheit should print a conversion table from Celsius to Fahrenheit, from 0 to +100 degrees Celsius, in steps of 5 degrees. Save the file ascelsius2FahrenheitaFirstinitialLastnam.c

Sample output:

Celsius                                          Fahrenheit

-----------------                                 -----------------    

0                                                    32

5                                                    41

10                                                  50

15                                                  59

20                                                  68

25                                                  77

30                                                  86

35                                                  95

40                                                  104

45                                                  113

50                                                  122

55                                                   131

60                                                  140

65                                                   149

70                                                   158

75                                                  167

80                                                   176

85                                                  185

90                                                   194

95                                                    203

100                                                  212

Hint: This program should be written exactly as the way it is written in C++ except the Input/Output part. You will need to use a for loop to accomplish this. Remember the control variable in the “for” statement must be declared outside of the for loop.

I need this written in a normal C program, not C++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>

int main() {
    int n;
    printf("Enter a dollar amount: ");
    scanf("%d", &n);
    printf("$20 bills: %d\n", n / 20);
    n %= 20;
    printf("$10 bills: %d\n", n / 10);
    n %= 10;
    printf("$5 bills: %d\n", n / 5);
    n %= 5;
    printf("$1 bills: %d\n", n);
    return 0;
}

#include <stdio.h>

int main() {
    double c;
    int f;
    printf("Fahrenheit\t\tCelsius\n");
    f = 100;
    while (f <= 400) {
        c = (f - 32) / 1.8;
        printf("  %3d\t\t\t%lf\n", f, c);
        f++;
    }
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
NOTE: ALL C PROGRAMS MUST BE DONE IN UNIX SYSTEM WITH VI EDITOR 1. Write a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use C++ and must be abke to compile on Visual Studios 9:27 ToDo Final Exam Grade...

    Use C++ and must be abke to compile on Visual Studios 9:27 ToDo Final Exam Grade Detail You need to implement C++ code that will read data from a file and process it as outlined below and write the processed data to an output file. You can refer to the file input.txt for how the data is made available to you and output.txt for how to write out the processed data. Your code will be tested using an input file...

  • Write a program that displays a table of Celsius temperatures 0 through a number entered by...

    Write a program that displays a table of Celsius temperatures 0 through a number entered by the user and their Fahrenheit equivalents as in the figure below. The formula for converting a Celsius temperature to a Fahrenheit temperature is: F = 9 / 5 * C + 32 where F is the Fahrenheit temperature and C is the Celsius Temperature. Your program must use a 'for' loop. Display all temperatures to one decimal place. Write a program that displays a...

  • Can someone help me out? c# For this Project, you will create a function called getTemperatures()....

    Can someone help me out? c# For this Project, you will create a function called getTemperatures(). The getTemperatures() function will have one parameter called temperatures[].Within the getTemperatures() function you will populate the temperatures array with the following values: 10,15,20,25,30,32,40,45,50,55,60,65,70. Your main program will traverse through the array and display the Fahrenheit and Celsius equivalents. Expected output 10 degrees Fahrenheit is -12 degrees Celsius 10 degrees Celsius is 50 degrees Fahrenheit 15 degrees Fahrenheit is -9 degrees Celsius 15 degrees Celsius...

  • In this Final program you are going to use several concepts you learned in CSC 101...

    In this Final program you are going to use several concepts you learned in CSC 101 class, especially operations on or using FILES , LOOPS and FUNCTIONS. You need to implement C++ code that will read data from a file and process it as outlined below and write the processed data to an output file. You can refer to the file input.txt for how the data is made available to you and output.txt for how to write out the processed...

  • please solve it using c++ coding Write a C++ program that outputs a table having four...

    please solve it using c++ coding Write a C++ program that outputs a table having four columns of temperature values, ordered as follow: Celsius, Fahrenheit, Kelvin and Rankine. Use a while loop Let the Celsius temperature vary from 0.0 to 100.0 in steps of 5 °C. Convert each of these values to the other scales using the formulas given in Lab-1 (reproduced here for your convenience): 1) KELVIN CELSIUS FAHRENHEIT RAN KINE 31SOLS 2672 273 MELTS 32 a. Fahrenheit (F):...

  • Write a program in C++ that gives the temperature of earth at a depth. It must...

    Write a program in C++ that gives the temperature of earth at a depth. It must be in C++ and follow the information below: Problem description Write a program to take a depth in kilometers inside the earth as input data; calculate and display the temperature at this depth in both degrees Celsius and degree Fahrenheit. The formulas are: Celsius temperature at depth in km: celsius = 10 x depth(km) + 20 Convert celsius to fahrenheit: fahrenheit = 1.8 x...

  • C++ requirements All values must be read in as type double and all calculations need to...

    C++ requirements All values must be read in as type double and all calculations need to be done using type double. For part 2 you MUST have at least 4 functions, including main. The main function will be the driver of the program. It needs to either do the processing or delegate the work to other functions. Failure to follow the C++ requirements could reduce the points received from passing the tests. General overview This program will convert a set...

  • Using the Windows Starter Visual Studio project create the following five programs. 1. Write a p...

    Using the Windows Starter Visual Studio project create the following five programs. 1. Write a program that will store address information in unique values and then display the full address in a window at runtime (10pts). Example: Sam Coder 1 Main Street Kansas City, MO 64018 2. Write a program that will swap the City and State fields and then display the full address in a window at runtime (10pts). Example: Sam Coder 1 Main Street MO, Kansas City 64018...

  • Using C++ 1. Create a while loop that counts even numbers from 2 to 10 2....

    Using C++ 1. Create a while loop that counts even numbers from 2 to 10 2. Create a for loop that counts by five (i.e. 0, 5, 10, ...) from 0 to 100 3. Ask for a person's age and give them three tries to give you a correct age (between 0 and 100) 4. Use a for loop to list Celsius and Fahrenheit temperatures. The "C" should be from -20 to 20 and the F should be shown correspondingly...

  • 1) Write a Unix command that will display the message below using echo and the value...

    1) Write a Unix command that will display the message below using echo and the value of your environment variable instead of the sample student login /students/astud01 My home directory is /students/astude01 2) Write a Unix command to display your login and the system date with both commands on one line (the output may be on separate lines) SAMPLE OUTPUT (details will differ): cconner Tue Jul 7 15:38:44 PDT 2015 3) 1.Write a Unix command that will redirect (>) the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT