Question
using C programming


Date Write a program that reads a month and a day in that month and prints the date in format month day. The input is two i
0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE:

#include <stdio.h>
int main(){
   char *months[] = {"January","February","March",
                                       "April","May","June","July",
                                       "August","September","October",
                                       "November","December"};

   int month,day;
   scanf("%d %d",&month,&day);

   printf(" %s ",months[month-1]);
   if(day==1 || day==21 || day==31){
       printf("%dst",day);
   }
   else if(day==2 || day==22){
       printf("%dnd",day);
   }
   else if(day==3 || day==23){
       printf("%drd",day);
   }
   else{
       printf("%dth",day);
   }
   return 0;
}

SCREENSHOT:

1 main.c #include <stdio.h> 2. int main() { 3 char *months[] = {January, February, March, 4 April, May, June, Ju

NOTE:

IF YOU HAVE ANY DOUBTS ASK IN COMMENT SECTION I WILL EXPLAIN YOU...

IF YOU LIKE THE ANSWER PLEASE GIVE ME UP VOTE

THANK YOU:)

Add a comment
Know the answer?
Add Answer to:
using C programming Date Write a program that reads a month and a day in that...
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
  • C programming! Write a program that reads integers until 0 and prints the sum of values...

    C programming! Write a program that reads integers until 0 and prints the sum of values on odd positions minus the sum of values on even positions. Let ?1, ?2, … , ??, 0 be the input sequence. Then the program prints the value of ?1 − ?2 + ?3 − ?4 + ⋯ ??. The input is a sequence of integers that always contains at least 0 and the output will be a single number. For example, for input...

  • C programming question! Write a program that reads two numbers and finds the greater one. The...

    C programming question! Write a program that reads two numbers and finds the greater one. The input is two integers and the output will be a single line “The maximum of ? and ? is ?.”, where ? and ? are the input values and ? is the maximum of ? and ?. If ? and ? are equal, ? will be equal to both of them. Example of input: 10 20 Corresponding output: The maximum of 10 and 20...

  • C++ PROGRAMMING: Define a class called Date that has 3 private members that represent the month,...

    C++ PROGRAMMING: Define a class called Date that has 3 private members that represent the month, day, and year respectively. They will be represented as integers. Include a constructor and a public void function called print that prints out the date. (For example, if the month is 2, the day is 25, and the year is 1946, print provides as output 2/25/1946.) Include the class in a program that prints out the date 2/25/1946. Also, create another function that will...

  • C programming help! Write a program that reads the electricity consumption (in kWh) and computes the...

    C programming help! Write a program that reads the electricity consumption (in kWh) and computes the electricity bill based on the following information: • The first 50 kWh costs 8.5 cents/kWh • Next 100 kWh costs 9.5 cents/kWh • Next 100 kWh costs 9.8 cents/kWh • The consumption above 250 kWh costs 10.25 cents/kWh Additional surcharge 20% is added to the bill. The input of the program is one integer and the output will be “The total bill is $?.”,...

  • C Program Question 1: Write a program that reads a date from the keyboard and tests...

    C Program Question 1: Write a program that reads a date from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format: mm/dd/yyyy Note that there is no space in the above format. A date in this format must be entered in one line. A valid...

  • Question 1: Write a program in C that reads a date from the keyboard and tests...

    Question 1: Write a program in C that reads a date from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format: mm/dd/yyyy Note that there is no space in the above format. A date in this format must be entered in one line. A valid...

  • C++ Programming question Problem: 5. Write a program that reads in a list of integers into...

    C++ Programming question Problem: 5. Write a program that reads in a list of integers into an array with base type int. Provide the facility to either read this array from the keyboard or from a file, at the user's option. If the user chooses file input, the program should request a file name. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries there are. The output is to be...

  • Programming language is C++. 9. Write a program that reads digits and composes them into integers....

    Programming language is C++. 9. Write a program that reads digits and composes them into integers. For example, 123 is read as the characters 1, 2, and 3. The program should output 123 is 1 hundred and 2 tens and 3 ones. The number should be output as an int value Handle numbers with one, two, three, or four digits. Hint: To get the integer value 5 from the character '5' subtract '0' that is, '5'-'0'

  • use vc++ to complete the programming project.... Number Array Version 1 (all interactive). Write a program...

    use vc++ to complete the programming project.... Number Array Version 1 (all interactive). Write a program that reads in the average monthly rainfall for a city for each month of the year and then reads in the actual monthly rainfall for each of the previous 12 months. The program then prints out a nicely formatted table showing the rainfall for each of the previous 12 months as well as how much above or below average the rainfall was for each...

  • FOR RUBY: ----------------------------------- Create a program named Gifts. This program will describe the gifts for the...

    FOR RUBY: ----------------------------------- Create a program named Gifts. This program will describe the gifts for the 12 Days of Christmas. Each day describes one gift only. You cannot explicitly output the list of gifts, you need to get each day to display. For instance, for the 3rd day of Christmas, you display the gift for the 3rd day, then display the gift for the 2nd day, then the gift for the 1st day. Think about the logic for this.. in...

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