16

Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C
Page 2: Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C

Contents i

Fundamentals of Computing

And Programming in C

Page 3: Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C

ii Contents

Page 4: Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C

Contents iii

Fundamentals of Computing

AndProgramming in C

T JEYAPOOVAN

ProfessorHindustan Institute of Technology and Science

Padur, Chennai

vikas publishing house pvt ltd

Page 5: Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C

iv Contents

All rights reserved. No part of this publication which is material protected by this copyright notice may be reproduced or transmitted or utilized or stored in any form or by any means now known or here-inafter invented, electronic, digital or mechanical, including photocopying, scanning, recording or by any information storage or retrieval system, without prior written permission from the publisher

Information contained in this book has been published by VIKAS® Publishing House Pvt Ltd and has been obtained by its Authors from sources believed to be reliable and are correct to the best of their knowledge. However, the Publisher and its Authors shall in no event be liable for any errors, omissions or damages arising out of use of this information and specifically disclaim any implied warranties or merchantability or fitness for any particular use. Disputes if any are subject to Delhi Jurisdiction only.

E-mail: [email protected] • Website: www.vikaspublishing.com

• Bengaluru : First Floor, N.S. Bhawan, 4th Cross, 4th Main, Gandhi Nagar, Bengaluru-560 009• Ph. 080-2220 4639, 2228 1254

• Chennai : Damodhar Centre, New No. 62, Old No. 59, Nelson Manickam Road, Aminjikarai, Chennai-600 029 • Ph. 044-2374 4547, 2374 6090

• Kolkata : 82, Park Street, Kolkata-700 017 • Ph. 033-2283 7880

• Mumbai : 67/68, 3rd Floor, Aditya Industrial Estate, Chincholi Bunder, Malad (West), Mumbai-400 064 • Ph. 022-2877 2545, 2876 8301

Published in 2015ISBN: 978-93-259-8109-6Vikas® is the registered trademark of Vikas Publishing House Pvt LtdCopyright © Author

VIKAS® PUBLISHING HOUSE PVT LTDE-28, Sector-8, Noida-201301Phone: 0120-4078900 • Fax: 0120-4078999Registered Office: 576, Masjid Road, Jangpura, New Delhi-110 014

Page 6: Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C

Contents v

Preface and Acknowledgements

This book is a perfect blend of concepts of computers and programming in C language. All that is required of a beginner programmer is not experience in computing but interest in computing.

This book is divided into three parts.

Part I deals with the fundamentals of computers, number systems, computer hardware, planning a computer program, algorithm, flowchart, pseudocode, problem solving and programming, stages in software development cycle and computer programming languages.

Part II deals with fundamentals of C programming. It provides exposure to write algorithm and flowcharting that help students write C programs effectively.

Part III deals with suggested laboratory exercises in C programming.

The programs illustrated in the book have been accumulated, experimented and tested by us during our teaching of this subject to thousands of students over many years. In addition, numerous problems are adapted from university question papers. Short questions and answers are an added feature. All these would build confidence of the students in computer programming.

I am highly indebted to the founder Chairman Dr. KCG Verghese and thanks to the Chancellor Dr. (Mrs.) Elizabeth Verghese; Pro Chancellor Dr. Anand Jacob Verghese; Vice-Chancellor Dr. S. Ramachandran and Directors, Dr. Aby Sam, Mr. Ashok Verghese, and Mr. KC Abraham, for their inspiration and encouragement in bringing out this book.

I am grateful to Dr. M. Rajeswari, Head, Department of Computer Science and Engineering, and his faculty for their encouragement and support. I thank Mr. S Saravanan, Mr. Rajararman and Mr. M Krishna for verifying the programs in the book. I acknowledge the continuous encouragement given by my brothers Mr. T Velsamy, Mr. T Ramachandran and Mr. T Narayanamoorthy. Finally, I acknowledge the patience and encouragement of my wife Sasi, daughters Soni and Sherin, who made this time of writing pleasant and enjoyable.

I hope this book will provide inspiration and help students in developing a strong foundation in computer programming. Suggestions for further improvement of the book are welcome. For assistance and clarifications, contact me through [email protected] or www.facebook.com/jeyapoovan.

T.JEYAPOOVAN

Page 7: Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C

vi Contents

Syllabus

This student-friendly text book has been prepared for learning fundamentals of computing and programming in C and it covers the syllabus requirement for the Under Graduate courses in Engineering in the following Indian Universities.

1. Anna University, Chennai

2. Kerala University, Thiruvananthapuram

3. Jawaharlal Nehru Technological University, Hyderabad

4. Mumbai University, Mumbai

5. Gujarat Technical University

6. G.B. Technical University, Lucknow

7. West Bengal Technical University and many more Indian Universities.

Page 8: Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C

B.E./B.TECH. SYLLABUS OF ANNA UNIVERSITY, CHENNAI

Subject Code and Name: GE6151 COMPUTER PROGRAMMING

S.No. Content Reference Chapters

Unit I INTRODUCTION

Generation and Classification of Computers- Basic Organ-ization of a Computer –Number System – Binary – Dec-imal – Conversion – Problems. Need for logical analysis and thinking – Algorithm – Pseudocode – Flow Chart.

Part I: Chapters 1 to 3

Part II: Chapter 1

Unit II C PROGRAMMING BASICS

Problem formulation – Problem Solving - Introduction to “C” programming –fundamentals – structure of a “C” program – compilation and linking processes – Con-stants, Variables – Data Types – Expressions using op-erators in “C” – Managing Input and Output operations – Decision Making and Branching – Looping statements – solving simple scientific and statistical problems.

Part I: Chapter 4

Part II: Chapters 2 to 5

Unit III ARRAYS AND STRINGS

Arrays – Initialization – Declaration – One dimensional and Two dimensional arrays. String- String operations – String Arrays. Simple programs- sorting- searching – matrix operations.

Part II: Chapters 6 and 7

Unit IV FUNCTIONS AND POINTERS

Function – definition of function – Declaration of func-tion – Pass by value – Pass by reference – Recursion – Pointers - Definition – Initialization – Pointers arithmetic – Pointers and arrays- Example Problems.

Part II: Chapters 8 and 10

Unit V STRUCTURES AND UNIONS

Introduction – need for structure data type – structure definition – Structure declaration – Structure within a structure - Union - Programs using structures and Un-ions – Storage classes, Pre-processor directives.

Part II: Chapters 9 and 12

Page 9: Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C

B.E./B.TECH. SYLLABUS OF KERALA UNIVERSITY, THIRUVANANTHAPURAM

Subject Code and Name: 13.109 FOUNDATIONS OF COMPUTING AND PROGRAMMING IN C

S.No. Content Reference Chapters

Module – I Introduction to digital computer – von Newman concept – A simple model of computer with acquisition of data, storage of data, processing of data, output of processed data. Details of functional units of a computer. Storage – primary storage and secondary storage.

Data representation – Number systems – Binary numbers - representation of integers – representation of fractions – octal and hexadecimal representations - conversion from one system to another - representation of BCD numbers. Simple arithmetic operations (addition, subtraction, mul-tiplication and division) on each representation. Floating point representation – normalization, arithmetic operations. Representation of characters in computer – ASCII, EBCDIC.

Part I:

Chapters 1 and 2

Module– II Introduction to programming languages: Types of pro-gramming languages - high level language, assembly language and machine language System software - Oper-ating systems – objectives of operating systems, compiler, assembler and interpreter (concepts only).

Problem Solving strategies: Problem analysis – formal definition of problem – Solution – top- down design – breaking a problem into sub problems- overview of the solution to the sub problems by writing step by step pro-cedure (algorithm) - representation of procedure by flow-chart - stepwise refinement of algorithm. Implementation of algorithms – use procedures to achieve modularity.

Examples for algorithms and flow charts: At least 10 problems (starting with non numerical examples and numeric problems like factorial, largest among three numbers, largest among N, Fibonacci etc) must be dis-cussed in detail.

Programming: Selection of appropriate variable names for memory address, documentation of programs, de-bugging, different types of errors, program testing and verification (preliminary treatment only).

Part I:

Chapters 3 to 5

Part II: Chapter 1

Page 10: Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C

Module–III Introduction to C Language: Preprocessor directives, header files, data types and qualifiers. Operators and expressions. Data input and output, control statements, arrays and strings – structures, unions, enumerated data type. Example programs including bubble sort, selection sort, linear search and binary search, two dimensional array, matrix operations etc.

Part II:

Chapters 1 to 7 and 9

Module–IV Pointers: Array of pointers, structures and pointers. Mem-ory allocation functions. Functions – function definition and function prototype. Function call by value and call by reference.

Scope rules and storage classes. Recursive functions – examples. Functions for implementation of stack and queue operations using array

Bitwise operations. Data files – formatted, unformatted and text files. Command line arguments – examples.

Part II:

Chapters 8, 10 and 11

Page 11: Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C

B.E./B.TECH. SYLLABUS OF JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY, HYDERABAD

Subject Code and Name: COMPUTER PROGRAMMING

S.No. Content Reference Chapters

Unit I Introduction to Computers – Computer Systems, Computing Environments, Computer Languages, Creating and running programs, Program Development.

Introduction to the C Language – Background, C Programs, Identifiers, Types, Variables, Constants, Input / Output, Op-erators(Arithmetic, relational, logical, bitwise etc.), Expres-sions, Precedence and Associativity, Expression Evaluation, Type conversions, Statements- Selection Statements(making decisions) – if and switch statements, Repetition statements ( loops)-while, for, do-while statements, Loop examples, other statements related to looping – break, continue, goto, Simple C Program examples.

Part I: Chapter 1

Part II: Chapters 1 to 5

Unit II Functions-Designing Structured Programs, Functions, user defined functions, inter function communication, Standard functions, Scope, Storage classes-auto, register, static, extern, scope rules, type qualifiers, recursion- recursive functions, Limitations of recursion, example C programs, Preprocessor commands.

Arrays – Concepts, using arrays in C, inter function communi-cation, array applications, two – dimensional arrays, multidi-mensional arrays, C program examples.

Part II: Chapters 6 and 8

Unit III Pointers – Introduction (Basic Concepts), Pointers for inter function communication, pointers to pointers, compatibility, Pointer Applications-Arrays and Pointers, Pointer Arithmetic and arrays, Passing an array to a function, memory allocation functions, array of pointers, programming applications, pointers to void, pointers to functions.

Strings – Concepts, C Strings, String Input / Output functions, arrays of strings, string manipulation functions, string / data conversion, C program examples.

Part II: Chapters 7 and 10

Page 12: Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C

Unit IV Enumerated, Structure ,and Union Types– The Type Defi-nition (typedef), Enumerated types, Structures –Declaration, initialization, accessing structures, operations on structures, Complex structures, structures and functions, Passing structures through pointers, self referential structures, unions, bit fields, C programming examples, command –line arguments, Input and Output – Concept of a file, streams, text files and binary files, Differences between text and binary files, State of a file, Opening and Closing files, file input / output functions (standard library input / output functions for files), file status functions (error handling),Positioning functions, C program examples

Part II: Chapters 9 and 11

Unit V Searching and Sorting – Sorting- selection sort, bubble sort, Searching-linear and binary search methods.

Lists- Linear list – singly linked list implementation, insertion, deletion and searching operations on linear list, Stacks- Push and Pop Operations, Queues- Enqueue and Dequeue operations.

Part II: Chapters 6 and 13

Page 13: Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C

B.E./B.TECH. SYLLABUS OF MUMBAI UNIVERSITY, MUMBAI

Subject Code and Name: FEC205 STRUCTURED PROGRAMMING APPROACH

S.No. Content Reference Chapters

1 Problem definition Part I: Chapter 4

2 AlgorithmsDeveloping AlgorithmsEfficiency of Algorithms

Part I: Chapter 3

3 Expressing Algorithm — SequenceExpressions in C; Arithmetic and Boolean expressionsUse of Standard functionsInput and outputAssignment statement

Part II: Chapters 1 to 3

4 Concept of scalar Data Typesscalar data types in C , Scope and life time, type conversion

Part II: Chapter 2

5 Expressing Algorithms — IterationOrdering a solution in a loopC- Control structures for Iteration

Part II: Chapter 5

6 Expressing Algorithms — SelectionC-Control structures for selection

Part II: Chapters 4 and 5

7 Decomposition of solutionDefining Functions in CFunctions and parametersIntroduction to recursive functions

Part II: Chapter 8

8 Additional C data typesArrays — single and multi dimensionalStringsStructuresFilesPointers

Part II: Chapters 6,7,9 to 11

Page 14: Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C

B.E./B.TECH. SYLLABUS OF GUJARAT TECHNOLOGICAL UNIVERSITY

Subject Code and Name: 2110003 COMPUTER PROGRAMMING AND UTILIZATION S.No. Content Reference Chapters

1 Introduction to computer and programmingIntroduction ,Basic block diagram and functions of var-ious components of computer, Concepts of Hardware and software, Types of softwares, Compiler and inter-preter, Concepts of Machine level, Assembly level and high level programming ,Flow charts and Algorithms.

Part I: Chapters 1, 3 and 5

Part II: Chapter 1

2 Fundamentals of ‘C’Features of C language, structure of C Program, com-ments, header files, data types, constants and variables, operators, expressions, evaluation of expressions, type conversion, precedence and associativity, I/O functions. Part II: Chapters 2 and 3

3 Control structure in ‘C‘Simple statements, Decision making statements, Looping statements, Nesting of control structures, break and continue, goto statement.

Part II: Chapters 4 and 5

4 Array & StringConcepts of array, one and two dimensional arrays, declaration and initialization of arrays, string, string storage, Built-in-string functions.

Part II: Chapters 6 and 7

5 FunctionsConcepts of user defined functions, prototypes, definition of function, parameters, parameter pass-ing, calling a function, recursive function, Macros, Pre-processing.

Part II: Chapters 8 and 12

6 PointersBasics of pointers, pointer to pointer , pointer and array , pointer to array, array of pointers , functions returning a pointer.

Part II: Chapter 10

7 StructureBasics of structure , structure members, accessing structure members ,nested structures , array of struc-tures, structure and functions, structures and pointers

Part II: Chapters 9 and 10

8 Dynamic memory allocationIntroduction to Dynamic memory allocation, malloac, Calloc

Part II: Chapter 10

9 File managementIntroduction to file management and its functions

Part II: Chapter 11

Page 15: Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C

B.E./B.TECH. SYLLABUS OF G.B. TECHNICAL UNIVERSITY, LUCKNOW

Subject Code and Name: NCS-101/NCS-201 Computer System and Programming

S.No. Content Reference Chapters

Unit I Basics of Computer: Introduction to digital computer, basic operations of computer, functional components of computer, Classification of computers.

Introduction to operating system: [DOS, Windows, Linux and Android] purpose, function, services and types.

Number system: Binary, octal and hexadecimal number systems, their mutual conversions, Binary arithmetic.

Basics of programming: Approaches to Problem Solving, Con-cept of algorithm and flow charts, Types of computer languag-es:- Machine Language, Assembly Language and High Level Language, Concept of

Assembler, Compiler, Loader and Linker.

Part I: Chapters 1 to 5

Part II: Chapter 1

Unit II Standard I/O in C, Fundamental data types- Character type, integer, short, long, unsigned, single and double floating point, Storage classes- automatic, register, static and external, Operators and expression using numeric and relational op-erators, mixed operands, type conversion, logical operators, bit operations, assignment operator, operator precedence and associativity.

Fundamentals of C programming: Structure of C program, writing and executing the first C program, components of C language. Standard I/O in C.

Part II: Chapters 1 to 3

Unit III Conditional program execution: Applying if and switch state-ments, nesting if and else, use of break and default with switch, program loops and iterations: use of while, do while and for loops, multiple loop variables, use of break and continue statements.

Functions: Introduction, types of functions, functions with array, passing values to functions, recursive functions.

Part II: Chapters 4, 5 and 8

Unit IV Arrays: Array notation and representation, manipulating array elements, using multi dimensional arrays. Structure, union, enumerated data types. Part II: Chapter 6 and 9

Unit V Pointers: Introduction, declaration, applications

File handling, standard C preprocessors, defining and calling macros, conditional compilation, passing values to the compiler.

Part II: Chapter 10 to 12

Page 16: Contents › ebooks › 2017 › 09 › 11726 › ... · programming, stages in software development cycle and computer programming languages. Part II deals with fundamentals of C

Fundamentals Of Computing AndProgramming In C

Publisher : SChand Publications ISBN : 9789325981096 Author : T Jeyapoovan

Type the URL : http://www.kopykitab.com/product/11726

Get this eBook

20%OFF