LAB 8.docx - CSL-113 Computer Programming Lab Semester BS CS – 01 Exercise 1 Write a C Program that contains one user defined function month o In main

LAB 8.docx - CSL-113 Computer Programming Lab Semester BS...

This preview shows page 1 - 2 out of 5 pages.

CSL-113: Computer Programming Lab Semester BS CS – 01 Exercise 1 Write a C++ Program that contains one user defined function month(). o In main() function: o Read an integer input in between (1 to 12) and store it month_of_year. o Call month(month_of_year) o In month() function : o Print the corresponding month of year in month(). o Example: Value of parameter is 4... Print “April”. Program #include <iostream> #include <string> using namespace std; string month( int x ); int main() { int month_of_year; cout << "Input an integer between 1 to 12 in order to return name of month: " ; cin >> month_of_year; cout << month(month_of_year) << endl; system( "pause" ); return 0; } string month( int x ) { if ( x == 1) return "January" ; else if ( x == 2) return "February" ; else if ( x == 3) return "March" ; else if ( x == 4) return "April" ; else if ( x == 5) return "May" ; else if ( x == 6) return "June" ; else if ( x == 7) return "July" ; else if ( x == 8) return "August" ; else if ( x == 9) return "September" ; else if ( x == 10) return "October" ; else if ( x == 11) return "November" ; else if ( x == 12) Department of Computer Sciences Page: 1/5 Semester BSCS 01 CSL-113: Computer Programming Lab Lab 08: Function-I
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read all 5 pages?

  • Summer '19

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors