![Download Download](/uploads/1/2/5/8/125841017/743189319.jpg)
Read & Download (PDF Kindle) Programming: Principles And Practice Using C (2nd Edition). Software development or in some other technical field. Programming #8:C Programming Success in a Day & Android Programming In a Day! (C Programming, Cprogramming, C programming language, Android, Android Programming. Programming: Principles. It’s recommended to download the latest version even if it’s in beta. When download is completed, open Xcode and follow the wizard to install it. You might want to put the Xcode in Applications for future use. Programming - Principles and Practice Using C (2nd Edition).
Home > Articles > Programming > C/C++
␡- Drill
< BackPage 8 of 12Next >
This chapter is from the book Programming: Principles and Practice Using C++, 2nd Edition
This chapter is from the book
This chapter is from the book
Programming: Principles and Practice Using C++, 2nd Edition
Drill
In this chapter, we have two drills: one to exercise arrays and one to exercise vectors in roughly the same manner. Do both and compare the effort involved in each.
Array drill:
- Define a global int array ga of ten ints initialized to 1, 2, 4, 8, 16, etc.
- Define a function f() taking an int array argument and an int argument indicating the number of elements in the array.
- In f():
- Define a local int array la of ten ints.
- Copy the values from ga into la.
- Print out the elements of la.
- Define a pointer p to int and initialize it with an array allocated on the free store with the same number of elements as the argument array.
- Copy the values from the argument array into the free-store array.
- Print out the elements of the free-store array.
- Deallocate the free-store array.
- In main():
- Call f() with ga as its argument.
- Define an array aa with ten elements, and initialize it with the first ten factorial values (1, 2*1, 3*2*1, 4*3*2*1, etc.).
- Call f() with aa as its argument.
Standard libraryvectordrill:
- Define a global vector<int> gv; initialize it with ten ints, 1, 2, 4, 8, 16, etc.
- Define a function f() taking a vector<int> argument.
- In f():
- Define a local vector<int> lv with the same number of elements as the argument vector.
- Copy the values from gv into lv.
- Print out the elements of lv.
- Define a local vector<int> lv2; initialize it to be a copy of the argument vector.
- Print out the elements of lv2.
- In main():
- Call f() with gv as its argument.
- Define a vector<int> vv, and initialize it with the first ten factorial values (1, 2*1, 3*2*1, 4*3*2*1, etc.).
- Call f() with vv as its argument.
Related Resources
- Book $63.99
![Pdf Pdf](/uploads/1/2/5/8/125841017/245983746.jpg)
- Book $23.99
- eBook (Watermarked) $51.19
Author: Bjarne Stroustrup
Publisher: Addison Wesley
Pages: 1312
ISBN: 978-0321992789
Print: 0321992784
Kindle: B00KPTEH8C
Audience: Beginners wanting to understand programming
Rating: 4.9
Reviewer: Mike James
Publisher: Addison Wesley
Pages: 1312
ISBN: 978-0321992789
Print: 0321992784
Kindle: B00KPTEH8C
Audience: Beginners wanting to understand programming
Rating: 4.9
Reviewer: Mike James
The second edition of a book that many regard as the best way to learn and teach C++.
Who better to learn C++ from than the man who invented C++ and depending on how you view things was, and is, a hero or set the course of programming back many years! C++ is a language that you either love or hate depending probably depending on whether or not you have had to debug someone else's C++ code.
The problem with C++ is that it is flexible, so flexible that you can write it in styles that make it look very different from the simple straightforward textbook approach. As a result many programmers believe that it's no place to start learning how to program.
Clearly Bjarne doesn't agree becauseProgramming:%20Principles%20and%20Practice%20Using%20C++
' target='_blank'> this book is aimed at the complete beginner. However, even if you are a complete novice you will probably want to skip the introduction (and perhaps even later bits) because the approach is very wordy.
This said it's all well written and well organised. Bjarne clearly understands programming, and the way you have to think to program, at a sufficiently high level to be able to reflect on the activity and understand what it is a beginner has to master and in what order. In short this is an excellent introduction to programming that just happens to use C++ as its target language.
It is clearly a student-oriented book and it is designed to be used on college courses - it has exercises. The notes to the reader go into the teaching philosophy used.
Chapter 1 is a very lightweight look at what computing is all about and is suitable as an introduction for any reader who has never seen or heard about computers.
The book really gets going at Chapter 2 which is where I suggest all readers should start. There is the usual hello world program, but it is important to know that the author uses a custom header file to make the examples in the rest of the book easier to use. It is important that the reader knows this and downloads the header from the author's web site. This isn't made clear, nor is where to store the file - it is expected that you can work this out. This could be the place that the real beginner without any help to call on gets completely stuck and gives up, so never reading the remaining 1000 plus pages of the book. This needs fixing.
From here the book moves though the basic topics of objects, expressions, functions, class and so on. It also deals with more general topics such has how to cope with errors and how to think about program creation. The chapter on how to think about creating a program includes a long discussion of grammar and how it relates to code.
What is strange is that the book proceeds very slowly in terms of what it explains - it tackles everything in simple prose and uses color to make everything look clean and simple. However, what it is explaining is quite advanced and sophisticated. It is a bit like reading a treatise on advanced quantum physics expressed in basic English - I kept thinking 'tell it to me like I'm five'. For example:
'... look at the calculation of the ratio in the code above. It look innocent enough. Did you notice something wrong with it? If not look again: area3 will be 0, so that double(area1)/area3 divides by zero. '
How you react to this sort of explanation is key to how you feel about the book. Some readers find it boring, tedious, insulting even. Me? I found it deeply relaxing and easy to read. How can anything be difficult when explained in this straightforward way? But remember this is C++ which has a reputation for biting programmers whenever they relax too much.
Part II, a sizable chunk of the book, is called 'Input and Output' which might seem a very narrow topic but interpreted in the full sense of data and graphics has a lot of ground to cover. It starts off with a look at streams and working with files, but it quickly moves on to graphics. Graphics is a good place to explain the ideas of object-oriented programming but there is also a lot to learn about GUIs and UIs.
Part III called 'Data and Algorithms' is more what you would expect in an 'educational' book on C++. It starts off with a look at the vector and how to manage storage. This leads on to a consideration of arrays and templates, i.e. generics, before moving into more complicated data structures - collections, linked lists and maps. You will also find discussions of algorithms and other computer science topics.
The final part of the book is called 'Broadening the View'. For most readers the view will have been fairly broad already so what to expect? Oddly Chapter 22 restarts the whole discussion of what is programming with a look at the history. This is odd because it is the sort of thing that is usually dealt with early in a book. Treating it at this point, however, allows it to be discussed with a bit more understanding. From here we move on to text manipulation as an example of a difficult subject area. Next numerics, with matrices and simple numerical algorithms. Chapter 25 gives the flavour of embedded programming - mostly bit manipulation. The book closes with a look at the ideas of testing and bit more on debugging and a look at the C programming language - which of course is more-or-less a subset of C++.
The collection of appendices include a definition of C++ and how to use Visual Studio.
This book would make an excellent course text book and it is one of the few that could succeed in teaching you C++ with good style and understanding just by reading it - but it is long and some are going to find it slow and plodding.
If you are looking for a book that has a jazzy layout, crazy humour, cartoons and gimmicks then you will be disappointed. There is humour, but it is very gentle and if you are in a hurry you might well miss it. Also the book isn't just an introduction to C++. It attempts to educate you in the wider issues and ideas of programming. This means that even though the presentation is slow paced you will need the intellectual apparatus to understand some of the subtle ideas.
Finally if you are a Bjarne Stroustrup fan then you will find this an excellent read.
Scratch Programming In Easy Steps (2e) Author: Sean McManus Publisher: In Easy Steps (2019) Pages: 216 ISBN: 978-1840788594 Print: 1840788593 Kindle: B00IDDZL78 Audience: Kids, their parents and teachers Rating: 5 Reviewer: Lucy Black What's Scratch all about and how do you use it? This book has the answer. |
C Programming Absolute Beginner's Guide (3e) Authors: Greg Perry & Dean Miller Publisher: Que Pages: 352 ISBN: 978-0789751980 Print: 0789751984 Kindle: B00EANJ09U Audience: Complete beginners Rating: 4.5 Reviewer: Mike James C a language for the absolute beginner! Can a book that uses C take you on the journey to become a programmer? |
More Reviews |