A Complete Guide to Programming in C++ part 40

A Complete Guide to Programming in C++ part 40. 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 369 Exercise I Given an array v with the following definition int v 10 20 30 40 i pv What screen output is caused by the following statements a. for pv cout v pv v pv 3 pv pv b. for pv v i 1 i 3 i cout pv i pv i c. for pv v i 0 pv i v 3 pv i cout pv i pv i d. for pv v 3 pv v --pv cout v pv - v v pv - v Exercise 2 Write a program that uses the cin method get to read a line character by character and stores it in a char line is then output in reverse order. Use a pointer not an index to address the array elements. Exercise 3 The standard function strcmp performs a lexicographical comparison of two C opposite page contains an index version of strcmp .The return value is the difference between two character codes. Write a pointer version of the function strcmp . Call this function str_cmp to distinguish it from the standard function. To test the function use a loop to read two lines of text and output the results of the loop should terminate when both strings are empty. Exercise 4 Define and test the function selectionSort that sorts an array of int values in ascending principle of the selection sort algorithm is shown opposite. Arguments An int array and its length Return values None Develop both an index version and a pointer the functions with random numbers between -10000 and 10000. 370 CHAPTER 17 ARRAYS AND POINTERS Notes on exercise 5 Sample environment strings for DOS Windows COMSPEC C PATH C WINDOWS C WINDOWS COMMAND C DOS D TOOLS PROMPT p g TEMP C TEMP Frequency table for exercise 7 Age Bloodpressure 120 120-129 130-139 140-149 160 20-29 25 34 26 12 8 30-39 19 27 24 11 4 40-49 6 15 35 36 18 EXERCISES 371 Exercise 5 a. Write a program that outputs its own name and all command line arguments each in a separate line. b. Now extend the program to output its own environment is a memory area containing strings in the format NAME String A third parameter for the function

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã 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.