ebook img

Intro To Comp-Wbut PDF

552 Pages·2008·6.972 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Intro To Comp-Wbut

About the Author E Balagurusamy, former Vice Chancellor, Anna University, Chennai, is currently Member, Union Public Service Commission, New Delhi. He is a teacher, trainer, and consultant in the fields of Information Technology and Management. He holds an ME (Hons) in Electrical Engineering and Ph.D. in Systems Engineering from the Indian Institute of Technology, Roorkee. His areas of interest include Object-Oriented Software Engineering, Electronic Business, Technology Management, Business Process Re-engineering, and Total Quality Management. A prolific writer, he has authored a large number of research papers and several books. His best selling books, among others, include: ∑ Programming in C#, 2e ∑ Programming in Java, 3/e ∑ Programming in ANSI C, 4/e ∑ Object-Oriented Programming with C++, 3/e ∑ Programming in BASIC, 3/e ∑ Numerical Methods ∑ Reliability Engineering A recipient of numerous honours and awards, he has been listed in the Directory of Who’s Who of Intellectuals and in the Directory of Distinguished Leaders in Education. E Balagurusamy Member, UPSC New Delhi Tata McGraw-Hill Publishing Company Limited NEW DELHI McGraw-Hill Offices New Delhi New York St Louis San Francisco Auckland Bogotá Caracas Kuala Lumpur Lisbon London Madrid Mexico City Milan Montreal San Juan Santiago Singapore Sydney Tokyo Toronto Published by Tata McGraw-Hill Publishing Company Limited, 7 West Patel Nagar, New Delhi 110 008. Copyright © 2008, by Tata McGraw-Hill Publishing Company Limited. No part of this publication may be reproduced or distributed in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise or stored in a database or retrieval system without the prior written per- mission of the publishers. The program listings (if any) may be entered, stored and executed in a computer system, but they may not be reproduced for publication. This edition can be exported from India only by the publishers, Tata McGraw-Hill Publishing Company Limited. ISBN (13 digits): 978-0-07-066864-5 ISBN (10 digits): 0-07-066864-7 Managing D irector: Ajay Shukla General Manager: Publishing—SEM & Tech Ed: Vibha Mahajan Asst. Sponsoring Editor: SEM & Tech Ed: Shalini Jha Editorial Executive: Nilanjan Chakravarty Executive—Editorial Services: Sohini Mukherjee Senior Production Executive: Anjali Razdan General Manager: Marketing—Higher Education & School: Michael J. Cruz Product Manager: SEM & Tech Ed: Biju Ganesan Controller—Production: Rajender P Ghansela Asst. General Manager—Production: B L Dogra Information contained in this work has been obtained by Tata McGraw-Hill, from sources believed to be reliable. However, neither Tata McGraw-Hill nor its authors guarantee the accuracy or completeness of any information published herein, and neither Tata McGraw-Hill nor its authors shall be responsible for any errors, omissions, or damages arising out of use of this information. This work is published with the understanding that Tata McGraw-Hill and its authors are supplying information but are not attempting to render engineering or other professional services. If such services are required, the assistance of an appropriate professional should be sought. Typeset at Script Makers, 19, A1-B, DDA Market, Paschim Vihar, New Delhi 110 063, text and cover printed at Ram Book Binding House, C-114, Okhla Industrial Area, Phase-I, New Delhi, 110020 Cover: Rashtriya Printer RQLLCDLYRQLRA Contents Preface xi Roadmap to the Syllabus xiii 1. Fundamentals of Computers 1 1.1 Introduction 1 1.2 History of Computers 2 1.3 Generations of Computers 5 1.4 Classification of Computers 8 1.5 Basic Anatomy of a Computer System 10 1.6 Input Devices 10 1.7 Processor 13 1.8 Output Devices 14 1.9 Memory Management 16 1.10 Overview of Operating System 17 Review Questions 23 2. Computing Concepts 25 2.1 Introduction 25 2.2 Binary Number System 25 2.3 Binary Codes 27 2.4 Binary Arithmetic Operations 28 2.5 Logic Gates 33 2.6 Programming Languages 37 2.7 Translator Programs 40 2.8 Algorithm and Flow Chart 41 2.9 Using the Computer 46 Review Questions 47 Review Exercises 47 3. Constants, Variables and Data Types 49 3.1 Introduction 49 3.2 Character Set 49 3.3 C Tokens 51 vi Contents 3.4 Keywords and Identifiers 51 3.5 Constants 52 3.6 Variables 56 3.7 Data Types 57 3.8 Declaration of Variables 60 3.9 Declaration of Storage Class 63 3.10 Assigning Values to Variables 64 3.11 Defining Symbolic Constants 70 3.12 Declaring a Variable as Constant 71 3.13 Declaring a Variable as Volatile 71 3.14 Overflow and Underflow of Data 72 Case Studies 73 Review Questions 75 Programming Exercises 77 4. Operators and Expressions 78 4.1 Introduction 78 4.2 Arithmetic Operators 78 4.3 Relational Operators 81 4.4 Logical Operators 82 4.5 Assignment Operators 83 4.6 Increment and Decrement Operators 85 4.7 Conditional Operator 86 4.8 Bitwise Operators 87 4.9 Special Operators 87 4.10 Arithmetic Expressions 89 4.11 Evaluation of Expressions 90 4.12 Precedence of Arithmetic Operators 91 4.13 Some Computational Problems 93 4.14 Type Conversions in Expressions 94 4.15 Operator Precedence and Associativity 98 4.16 Mathematical Functions 100 Case Study 102 Review Questions 104 Programming Exercises 107 5. Managing Input and Output Operations 110 5.1 Introduction 110 5.2 Reading a Character 111 5.3 Writing a Character 114 5.4 Formatted Input 115 5.5 Formatted Output 124 Case Studies 132 Contents vii Review Questions 136 Programming Exercises 138 6. Decision Making and Branching 140 6.1 Introduction 140 6.2 Decision Making with if Statement 140 6.3 Simple if Statement 141 6.4 The if.....else Statement 145 6.5 Nesting of if....else Statements 148 6.6 The else if Ladder 152 6.7 The switch Statement 155 6.8 The ? : Operator 159 6.9 The Goto Statement 161 Case Studies 165 Review Questions 169 Programming Exercises 174 7. Decision Making and Looping 177 7.1 Introduction 177 7.2 The while Statement 179 7.3 The do Statement 182 7.4 The for Statement 184 7.5 Jumps in Loops 191 Case Studies 200 Review Questions 207 Programming Exercises 211 8. User-Defined Functions 214 8.1 Introduction 214 8.2 Need for User-defined Functions 214 8.3 A Multi-function Program 215 8.4 Elements of User-defined Functions 218 8.5 Definition of Functions 219 8.6 Return Values and their Types 221 8.7 Function Calls 222 8.8 Function Declaration 224 8.9 Category of Functions 226 8.10 No Arguments and No Return Values 226 8.11 Arguments but No Return Values 229 8.12 Arguments with Return Values 232 8.13 No Arguments but Returns a Value 236 8.14 Functions that Return Multiple Values 237 viii Contents 8.15 Nesting of Functions 238 8.16 Recursion 240 8.17 Passing Arrays to Functions 241 8.18 Passing Strings to Functions 246 8.19 The Scope, Visibility and Lifetime of Variables 247 8.20 Multifile Programs 257 Case Study 260 Review Questions 263 Programming Exercises 267 9. The Preprocessor 269 9.1 Introduction 269 9.2 Macro Substitution 270 9.3 File Inclusion 274 9.4 Compiler Control Directives 275 Review Questions 278 Programming Exercises 279 10. Arrays 280 10.1 Introduction 280 10.2 One-dimensional Arrays 282 10.3 Declaration of One-dimensional Arrays 283 10.4 Initialization of One-dimensional Arrays 285 10.5 Two-dimensional Arrays 289 10.6 Initializing Two-dimensional Arrays 293 10.7 Multi-dimensional Arrays 298 10.8 Dynamic Arrays 298 10.9 More about Arrays 299 Case Studies 300 Review Questions 312 Programming Exercises 315 11. Character Arrays and Strings 318 11.1 Introduction 318 11.2 Declaring and Initializing String Variables 319 11.3 Reading Strings from Terminal 320 11.4 Writing Strings to Screen 325 11.5 Arithmetic Operations on Characters 330 11.6 Putting Strings Together 331 11.7 Comparison of Two Strings 333 11.8 String-handling Functions 333 Contents ix 11.9 Table of Strings 338 11.10 Other Features of Strings 340 Case Studies 341 Review Questions 345 Programming Exercises 348 12. Pointers 350 12.1 Introduction 350 12.2 Understanding Pointers 350 12.3 Accessing the Address of a Variable 353 12.4 Declaring Pointer Variables 354 12.5 Initialization of Pointer Variables 355 12.6 Accessing a Variable Through Its Pointer 357 12.7 Chain of Pointers 359 12.8 Pointer Expressions 360 12.9 Pointer Increments and Scale Factor 361 12.10 Pointers and Arrays 363 12.11 Pointers and Character Strings 366 12.12 Array of Pointers 368 12.13 Pointers as Function Arguments 369 12.14 Functions Returning Pointers 372 12.15 Pointers to Functions 372 12.16 Pointers and Structures 375 Case Studies 378 Review Questions 383 Programming Exercises 386 13. Structures and Unions 387 13.1 History of Computers 387 13.2 Defining a Structure 387 13.3 Declaring Structure Variables 389 13.4 Accessing Structure Members 391 13.5 Structure Initialization 392 13.6 Copying and Comparing Structure Variables 394 13.7 Operations on Individual Members 396 13.8 Arrays of Structures 397 13.9 Arrays within Structures 399 13.10 Structures within Structures 401 13.11 Structures and Functions 403 13.12 Unions 405 13.13 Size of Structures 407 13.14 Bit Fields 407 x Contents Case Studies 411 Review Questions 414 Programming Exercises 418 14. File Management in C 420 14.1 Introduction 420 14.2 Defining and Opening a File 421 14.3 Closing a File 422 14.4 Input/Output Operations on Files 423 14.5 Error Handling During I/O Operations 429 14.6 Random Access to Files 431 14.7 Command Line Arguments 436 Review Questions 439 Programming Exercises 440 15. Developing a C Program: Some Guidelines 442 15.1 Introduction 442 15.2 Program Design 442 15.3 Program Coding 444 15.4 Common Programming Errors 446 15.5 Program Testing and Debugging 453 15.6 Program Efficiency 455 Review Questions 456 Solved Question Papers: 2003–2007 458–518 Model Question Papers 519–537 Bibliography 538

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.