TAILIEUCHUNG - C++ Lab 8 Functions

When we build a house why do we make rooms? In our daily life why do we use so many different people who specialize in different professions, such as physicians, lawyers, accountants, etc? Same reasoning can be applied to programming. When we write a good program, it must be divided into modules; each module is designed to do a particular task. In C++ there are two types of modules, functions and classes. In this chapter we will deal with functions. You can write functions that can be used over and over again in a program or in several programs. In. | Lab 8 F unctions When we build a house why do we make rooms In our daily life why do we use so many different people who specialize in different professions such as physicians lawyers accountants etc Same reasoning can be applied to programming. When we write a good program it must be divided into modules each module is designed to do a particular task. In C there are two types of modules functions and classes. In this chapter we will deal with functions. You can write functions that can be used over and over again in a program or in several programs. In fact the C standard library comes with many functions for mathematical string and character manipulations. A large programming job needs to be broken down to manageable smaller modules this breaking down process is called top down design. Here is a popular poem written using functions. I have broken down the poem into four functions four verses and one chorus. The main function simply calls the other functions. Even though the program is given in two text boxes for clarity please combine them into one program. Program 8-1 Program Function Calls Written by Dr. John P. Abraham Instructional objective Functions include iostream using namespace std void chorus void verse1 void verse2 void verse3 void verse4 int main verse1 chorus verse2 chorus verse3 chorus verse4 chorus return 0 Program 2-1 continued __ void chorus cout nTwinkle twinkle little star cout nHow I wonder what you are cout nUp above the world so high cout nLike a diamond in the sky n void verse1 cout nWhen the blazing sun is gone cout nWhen he nothing shines upon cout nThen you show your little light cout nTwinkle twinkle all the night. n void verse2 cout nThen the traveler in the dark cout nThanks you for your tiny spark cout nHe could not see which way to go cout nIf you did not twinkle so. n void verse3 cout nIn the dark blue sky you keep cout nAnd often through my curtains peep cout nFor you never shut your eye cout nTill the

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.