Write a program to generate and display a table of n and n2


1. Write a program to generate and display a table of n and n2, for integer values of n ranging from 1 through 10. Be sure to print appropriate column headings.

2. Write a C program that prompts for a variable number of integers, adds them up, averages them, and prints out the average The user will enter either an integer to be averaged or a sentinel of 999 indicating that no more numbers are to be entered. When the sentinel is entered, the program will exit the repetition loop. It will then compute and display the average of numbers entered.

3. Write a C function named change() that accepts a floating point number of total coins and the addresses of the integer variables named quarters, dimes, nickels, and pennies. The function should determine the number of quarters, dimes, nickels, and pennies in the total coins number passed to it and write these values directly into the respective variables declared in its calling function using pointers.

Call the function change() from main() three times and print out the contents of the variables quarters, dimes, nickels, and pennies after each function return. First Call-pass in the total value $1.88 and on return print the contents of the variables. Second Call-pass in the total value .32 and on return print the contents of the variables. Third Call- ask for a total value input from the keyboard and on return print the contents of the variables.
Output should look like:
TOTAL VALUE ENTERED: 1.88
7 quarters
1 dime
0 nickels
3 pennies
and not:
TOTAL VALUE ENTERED: 1.88
7 quarters
18 dimes
37 nickels
188 pennies


4. Write a C function named liquid() that is to accept an integer number
and the addresses of the variables gallons, quarts, pints, and
cups. The passed integer represents the total number of cups, and the
function is to determine the number of gallons, quarts, pints, and cups in
S-13
the passed value. Using the passed addresses, the function should
directly alter the respective variables in the calling function. Use the
relationships of 2 cups to a pint, 4 cups to a quart, and 16 cups to a gallon.
Include this function in a program, printing the results after the function
has run.
If the user enters 27 cups, the output should be:
1 gallon
2 quarts
1 pint
1 cup
and not:
1 gallon
6 quarts
13 pints
27 cups

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Write a program to generate and display a table of n and n2
Reference No:- TGS0128118

Expected delivery within 24 Hours