Question

Write a C program with a function that displays a list of months, the number of...

Write a C program with a function that displays a list of months, the number of days in each month, and the month with the least amount of days.  

Use a two-dimensional character array for the months and a one-dimensional integer array for the number of days in each month.

Include another function that returns the index of the month with the least amount of days.

Function Prototypes:

void DisplayMonths( char months[ROW][COL], int days[ ROW ] );

int min( int days[ ROW] );

0 0
Add a comment Improve this question Transcribed image text
Answer #1
void DisplayMonths( char months[ROW][COL], int days[ ROW ] ){
   printf("Month\t\t\tDays\n");
   printf("--------------------------------\n");
   for(int i = 0;i<12;i++){
      printf("%s\t\t\t%d\n",months[i], days[i]);
   }
}

int min( int days[ ROW] ){
   int index = 0;
   for(int i = 1;i<12;i++){
      if(days[index] > days[i]){
         index = i;
      }
   }
   return index;
}
Add a comment
Know the answer?
Add Answer to:
Write a C program with a function that displays a list of months, the number of...
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
  • Consider the following program that reads a number of nonnegative integers into an array and prints...

    Consider the following program that reads a number of nonnegative integers into an array and prints the contents of the array.   Complete the missing parts, add new function prototypes and function definitions, and test the program several times. Add the following to the program: Write a void function that prints the list of nonnegative integers in reverse. Write a void function that prints all the numbers stored in the list that are greater than 10. It will also print the...

  • I need a c++ code please. 32. Program. Write a program that creates an integer constant...

    I need a c++ code please. 32. Program. Write a program that creates an integer constant called SIZE and initialize to the size of the array you will be creating. Use this constant throughout your functions you will implement for the next parts and your main program. Also, in your main program create an integer array called numbers and initialize it with the following values (Please see demo program below): 68, 100, 43, 58, 76, 72, 46, 55, 92, 94,...

  • Intro to Programming in C – Large Program 1 – Character/ Number converter Assignment Purpose: To...

    Intro to Programming in C – Large Program 1 – Character/ Number converter Assignment Purpose: To compile, build, and execute an interactive program with a simple loop, conditions, user defined functions and library functions from stdio.h and ctype.h. You will write a program that will convert characters to integers and integers to characters General Requirements • In your program you will change each letter entered by the user to both uppercase AND lowercase– o Use the function toupper in #include...

  • Do the following: - Write and test a function that takes an array of doubles and...

    Do the following: - Write and test a function that takes an array of doubles and returns the average of the values in the array - Write and test a function that takes an array of doubles and returns number of values in the array that are above the average of the values in the array - Write and test a function that takes an array of Strings and returns number of values in the array that start with an...

  • Can someone explain this code with comments I am supposed to dispay an array an add...

    Can someone explain this code with comments I am supposed to dispay an array an add each columns and add each row An application uses a two-dimensional array declared as follows: int[][] days = new int[29][5]; a. Write code that sums each row in the array and displays the results. b. Write code that sums each column in the array and displays the results. class TwoDimensionalArrayDemo { public static void main( String[] arg ) { int[][] days = new int[29][5];...

  • C++ SECTION 1) (15 points) Write a full C++ program that reads an integer, a list...

    C++ SECTION 1) (15 points) Write a full C++ program that reads an integer, a list of words, and a character. The integer signifies how many words are in the list. The output of the program is every word in the list that contains the character at least once. Assume at least one word in the list will contain the given character. Ex: If the input is: 4 hello zoo sleep drizzle z then the output is: 200 drizzle To...

  • Please help!! I am supposed to write a program in C++ about student & grades. Needs...

    Please help!! I am supposed to write a program in C++ about student & grades. Needs to have two functions that sorts students letter grade, and another one to sort Students name in your student’s record project. Remember, to add necessary parameters and declaration in main to call each function properly. Order of functions call are as follow Read Data Find Total Find average Find letter grade Call display function Call sort letter grade function Call display function Call sort...

  • I am using C++ Write a program to determine if a gird follows the rules to...

    I am using C++ Write a program to determine if a gird follows the rules to be classified as a Lo Shu Magic Square. The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown in figure below. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 through 9 exactly. The sum of each row, each column, and each diagonal all add up to the same number. This is shown...

  • Using the program segment below, write two short functions to complete the program. Use the test...

    Using the program segment below, write two short functions to complete the program. Use the test cases to ensure the program works properly. Prototypes: void int2bin(int, int[8]); The first function will convert an integer that is between 0 - 255 to its binary representation. You are to store the binary number in the array passed to the function. void printBinary(int[8]); The second function will print the binary number stored in the array passed to the function. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Test 1: 13...

  • I need help programming this program in C. 1.) Write a program that reads a message,...

    I need help programming this program in C. 1.) Write a program that reads a message, then checks whether it's a palindrome (the letters in the message are the same from left to right as from right to left), example is shown below: Enter a message: He lived as a devil, eh? Palindrome Enter a message: Madam, I am Adam. Not a Palindrome 2.) Ignore all characters that aren't letters. Use integer variables to keep track of positions in 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