TAILIEUCHUNG - A Complete Guide to Programming in C++ part 18

A Complete Guide to Programming in C++ part 18. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | EXERCISES 149 Exercise I A function has the following prototype void func unsigned int n What happens when the function is called with -1 as an argument Exercise 2 How often is the following loop executed unsigned int limit 1000 for int i -1 i limit i . . . Exercise 3 What is output when the program opposite is executed Exercise 4 Write a C program to output the sine curve on screen as in the graphic shown on the opposite page. NOTE 1. Plot one point of the curve in columns 10 10 1 . 10 64 leads to a step value of 2 PI 64 for x. 2. Use the following extended ASCII code characters to draw the axes Character Decimal Octal 196 304 197 305 16 020 30 036 Example cout 020 up arrowhead 150 CHAPTER 8 CONVERTING ARITHMETIC TYPES SOLUTIONS Exercise I When called the value -1 is converted to parameter n unsigned int. The pattern of -1 is interpreted as unsigned which yields the greatest unsigned value. On a 32-bit system -1 has the bit pattern OxFFFFFFFF which when interpreted as unsigned corresponds to the decimal value 4 294 967 295. Exercise 2 The statement within the loop is not executed at all In the expression i limit the value of variable i -1 is implicitly converted to unsigned int and thus it represents the greatest unsigned value see Exercise I . Exercise 3 The screen output of the program v_char v_short v_ushort v_ulong v_float int v_float A 65 -2 fffe 65534 fffe fffffffe -1 Exercise 4 --------------------------------------------------------------- Outputs a sine curve --------------------------------------------------------------- include iostream include cmath using namespace std Prototypes of sin define CLS cout 033 2J define LOCATE z s cout 033 z s H define PI define START Lower limit define END PI Upper limit SOLUTIONS 151 define PNT 64 Number of points on the curve define STEP END-START PNT define xA 14 Row of x-axis define yA 10 Column of y-axis int main int row column CLS LOCATE 2 25 cout .

TỪ KHÓA LIÊN QUAN
Đã 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.