TAILIEUCHUNG - c for engineers and scientists introduction to programming with ansi c phần 4

Viết một chương trình mà chấp nhận hai số thực và mã một lựa chọn từ người dùng. Nếu mã chọn nhập 1, có chương trình thêm hai con số nhập vào trước đó và hiển thị kết quả, nếu mã lựa chọn là 2, các con số cần được nhân rộng, và nếu mã lựa chọn là 3, số đầu tiên nên được chia số thứ hai. | 184 Chapter Four Selection Additional Exercises for Chapter 4 1 a. Write a program that accepts two real numbers and a select code a from user. If the entered select code is 1 have the program add the two previously entered numbers and display the result if the select code is 2 the numbers should be multiplied and if the select code is 3 the first number should be divided by the second number. b. Determine what the program written in Exercise la does when the entered numbers are 3 and 0 and the select code is 3. c. Modify the program written in Exercise la so that division by 0 is not allowed and that an appropriate message is displayed when such a division is attempted. 2 a. Write a program to display the following two prompts Enter a month use a 1 for Jan etc. Enter a day of the month Have your program accept and store a number in the variable month in response to the first prompt and accept and store a number in the variable DAY in response to the second prompt. If the month entered is not between 1 and 12 inclusive print a message informing the user that an invalid month has been entered. If the day entered is not between 1 and 31 print a message informing the user that an invalid day has been entered. b. What will your program do if the user types a number with a decimal point for the month How can you ensure that your if statements check for an integer number c. In a non-leap year February has 28 days the months January March May July August October and December have 31 days and all other months have 30 days. Using this information modify the program written in Exercise 2a to display a message when an invalid day is entered for a user-enentered month. For this program ignore leap years. 3 a. The quadrant that a line drawn from the origin resides in is determined by the angle that the line makes with the positive X axis as follows Angle from the Positive X Axis Quadrant Between 0 and 90 degrees I Between 90 and 180 degrees II Between 180 and 270 degrees III .

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.