1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Lab 4 selection statements

4 0 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Course Programming Fundamentals (C language) 1 LAB 4 – Selection Statements Main content 1 Get used to simple selection statements 2 Get used to nested selection statements 3 Start complex data proces[.]

Course: Programming Fundamentals (C language) LAB – Selection Statements Main content: Get used to simple selection statements Get used to nested selection statements Start complex data processing Check coding styles Practice: Get used to simple selection statements 1.1 Write a C program to perform a simple calculation between two numbers input by a user from the keyboard Calculation is requested from a starting menu as follows: What kind of calculation you want? a + b a – b a * b a / b None Please enter your choice (1 for addition, for subtraction, for multiplication, for division, or for none to exit the calculation program): 1.2 Write a C program to check if a character input by a user from the keyboard is a digit, a punctuation mark, an alphabetic letter, a bracket, or other special character Print a corresponding check result along with the input character If the user enters ‘#’, the program is ended with a prompt message: “END” 1.3 Write a C program to check the characteristics of a polygon in a two-dimensional space according to the vertices input by a user from the keyboard as follows: If there is one vertex, check if the polygon lies on the x axis or the y axis or both If there are two distinct vertices, check if the polygon is a square or a rectangle whose has edges parallel to the axes If there are three distinct vertices, check if the polygon is an equilateral, isosceles, or squared triangle An equilateral triangle is a triangle with all the sides of the same length An isosceles triangle is a triangle with two sides of the same length A squared triangle is a triangle with a 90o angle Otherwise, print a message: “Undiscovered polygons” 1.4 Write a C program to calculate a distance in day between two given dates input by a user from the keyboard It is noted that a leap year has February with 29 days instead of 28 days How many days are there between 15/01/2016 and 22/06/2017? How many days are there between 24/05/2017 and 29/06/2017? Get used to nested selection statements 2.1 Write a C program to solve a quadratic equation a*x2 + b*x + c = where a, b, c, and x are any floating-point numbers input by a user from the keyboard 2.2 Write a C program to calculate the cost for travelling from point A to point B in a 2-D space by taxi with the following price board as follows: Distance (km) 0

Ngày đăng: 11/04/2023, 18:46

Xem thêm:

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN

w