Skip to content

MyUstaadG

Learn to Serve

  • Computer Science
    • Software
    • Computer Tips
    • Coding
      • Conditional Structures Exercises
      • Loops Exercises
      • Arrays Exercises
      • Python Exercises
    • Microsoft Office
      • MS Excel
      • MS Word
  • Videos
    • Funny Videos
    • Health and Fitness Videos
    • PUBG Videos
    • Technology Videos
  • News
  • Funny
  • Memes
  • Playwright Tutorials
  • Tutorials
  • Toggle search form

Write a program that inputs any number of month of the year and displays the name and number of days of the entered month

Posted on September 29, 2021October 6, 2021 By myustaadg.com
Spread the love

Write a program that inputs any number of month of the year and displays the name and number of days of the entered month. For example, if 4 is entered for the number of month of the year, program should display “April has 30 days”.

Introduction to C++ Programming | Download and Install Dev C++ Compiler

So let’s Write Code:

Algorithm

  • Start
  • Input month number in a variable
  • if month number is 1 then display January has 31 days and so on,
  • Add conditions for the remaining 11 months
  • End

Write a program that inputs any number of months of the year and displays the name and number of days of the entered month. For example, if 4 is entered for the number of months of the year, the program should display “April has 30 days”.

#include"iostream"
using namespace std;
main()
{
int no_month;

cout<<"Enter number of month of the year [1-12]?"<<endl;
cin>>no_month;
if(no_month == 1)
cout<<"January has 31 days ";
else if(no_month == 2)
cout<<"February has 28 days ";
else if(no_month == 3)
cout<<"March has 31 days ";
else if(no_month == 4)
cout<<"April has 30 days ";
else if(no_month == 5)
cout<<"May has 31 days ";
else if(no_month == 6)
cout<<"June has 30 days ";
else if(no_month == 7)
cout<<"July has 31 days ";
else if(no_month == 8)
cout<<"August has 31 days ";
else if(no_month == 9)
cout<<"September has 30 days ";
else if(no_month == 10)
cout<<"October has 31 days ";
else if(no_month == 11)
cout<<"November has 30 days ";
else if(no_month == 1)
cout<<"December has 31 days ";

}

Hope You will learn Something From Here:

Visit my YouTube Channel as Well.

https://www.youtube.com/channel/UCzLCFHk47BV-NLJbTpBdRHw

Conditional Structures Exercises Tags:Basic Programs In C++, C++ Coding Guideline, Class Programs In C++, Coding Convention C++ Namespace, Coding Examples C++, Coding Ground C++, Coding In C++ For Beginners, Coding In C++ Online, Coding Websites C++, Coding With C++, Complex Number Program In C++, Constructor Programs In C++, Data Structures Programs In C++, Dev C++, Example Programs In C++, Exception Handling Programs In C++, For Loop Programs In C++, Function Overloading Programs In C++, Function Programs In C++, Game Programs In C++, Graphics Programs In C++, How To Create Programs In C++, How To Make Programs In C++, How To Write Programs In C++, Huffman Coding In C++, If Else Programs In C++, If Programs In C++, Implementation Of Stack Using Array In C++ Programs, In C++ Programs The Keyword Friend Appears In The, Inheritance Programs In C++, Interview Programs In C++, mohammad umar, myustaadg, Number Pattern Programs In C++, Object Code, Oops Programs In C++, Operator Overloading Programs In C++, Pattern Programs In C++, Programming In C++ Questions And Answers, Programs In C++ Examples, Programs In C++ For Beginners, Programs In C++ Pdf, Programs In C++ Using Class, Programs In Turbo C++, Programs Of C++, Programs Of C++ Language, Queue Program In C++, Sorting Programs In C++ Simple Programs In C++, Source Code, Stack Programs In C++, String Programs In C++, Structure Programs In C++, Template Program In C++, Writing Programs In C++

Post navigation

Previous Post: Write a program that converts ASCII number to character or character to ASCII number. The program should display the menu for conversion options
Next Post: Write a program that calculates income tax for three categories of income groups. The tax is computed as follows

More Related Articles

Write a program that inputs a year such as 1996, 1800, and 2010, and displays “Leap year” if it is a leap year, otherwise displays “Not a leap year” Conditional Structures Exercises
Write a program that performs simple arithmetic calculations using ‘nested if-else’ structure Conditional Structures Exercises
Write a program that inputs an integer and displays the corresponding name of day of the week using switch selection structure Conditional Structures Exercises
Write a program that displays the following menu for Toll Plaza rates C- Car B- Bus T- Truck Conditional Structures Exercises
Write a program to input a single character and print the message “ It is a vowel” if it is vowel otherwise print “It is a consonant”. Use the ‘switch’ selection structure Conditional Structures Exercises
Write a program that inputs the radius of a circle. It calculates area of circle if user enters 1 as choice. It calculates circumference of the circle if the user enters 2 as choice Conditional Structures Exercises

Copyright © 2022 MyUstaadG.

Powered by PressBook Blog WordPress theme