Primer Plus. Fourth Edition. Stephen Prata. 800 East 96th St., Indianapolis, Indiana, USA

Size: px
Start display at page:

Download "Primer Plus. Fourth Edition. Stephen Prata. 800 East 96th St., Indianapolis, Indiana, USA"

Transcription

1

2 C Primer Plus Fourth Edition Stephen Prata 800 East 96th St., Indianapolis, Indiana, USA

3 C Primer Plus, Fourth Edition Copyright 2002 by Sams Publishing All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein. International Standard Book Number: Library of Congress Catalog Card Number: Printed in the United States of America First Printing: September Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Apple is a registered trademark of Apple Computer, Inc. Borland C++ is a registered trademark of Borland International, Inc. CodeWarrior is a registered trademark of Metrowerks, Inc. Cray is a registered trademark of Cray Computer, Inc. IBM and PC are registered trademarks and PC DOS is a trademark of the International Business Machines Company. Macintosh is a registered trademark of Macintosh Laboratory, Inc., licensed by Apple Computer, Inc. Microsoft and MS-DOS are registered trademarks of Microsoft Corporation. Primer Plus is a registered trademark of The Waite Group, Inc. Think C is a registered trademark of Symantec Corporation. Turbo C is a registered trademark of Borland International, Inc. Unix is a trademark of American Telephone and Telegraph Corporation. VAX is a registered trademark and VMS is a trademark of Digital Equipment Corporation. Windows is a registered trademark of Microsoft Corporation. WordPerfect is a registered trademark of WordPerfect Corporation. WordStar is a registered trademark of MicroPro International Corporation. Warning and Disclaimer Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an as is basis. The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book or from the use of the Web site or programs accompanying it. ASSOCIATE PUBLISHER Linda Engelman ACQUISITIONS EDITORS Linda Scharp Karen Wachs DEVELOPMENT EDITOR Karen Wachs MANAGING EDITOR Charlotte Clapp PROJECT EDITOR Sheila Schroeder COPY EDITOR Pat Kinyon INDEXER Sandra Henselmeier PROOFREADER Plan-It Publishing TECHNICAL EDITOR Jeff Perkins Chris Maunder TEAM COORDINATORS Chris Feather Lynne Williams MEDIA DEVELOPER Dan Scherf INTERIOR DESIGNER Gary Adair PAGE LAYOUT Tim Osborn

4 CONTENTS AT A GLANCE PREFACE xx CHAPTER 1 Getting Ready CHAPTER 2 Introducing C CHAPTER 3 Data and C CHAPTER 4 Character Strings and Formatted Input/Output CHAPTER 5 Operators, Expressions and Statements CHAPTER 6 C Control Statements: Looping CHAPTER 7 C Control Statements: Branching and Jumps CHAPTER 8 Character Input/Output and Redirection CHAPTER 9 Functions CHAPTER 10 Arrays and Pointers CHAPTER 11 Character Strings and String Functions CHAPTER 12 Storage Classes, Linkage, and Memory Management CHAPTER 13 File Input/Output CHAPTER 14 Structures and Other Data Forms CHAPTER 15 Bit Fiddling CHAPTER 16 The C Preprocessor and the C Library CHAPTER 17 Advanced Data Representation APPENDIX A Answers to the Review Questions APPENDIX B Reference Section INDEX 871

5 TABLE OF CONTENTS CHAPTER 1: Getting Ready Whence C? Why C? Design Features Efficiency Portability Power and Flexibility Programmer Oriented Shortcomings Whither C? What Computers Do High-Level Computer Languages and Compilers Using C: Seven Steps Step 1: Define the Program Objectives Step 2: Design the Program Step 3: Write the Code Step 4: Compile Step 5: Run the Program Step 6: Test and Debug the Program Step 7: Maintain and Modify the Program Commentary Programming Mechanics Object Code Files, Executable Files, and Libraries UNIX System Linux System Integrated Development Environments (Windows) DOS Compilers for the IBM PC C on the Macintosh Language Standards The First ANSI/ISO C Standard The C99 Standard Book Organization Some Conventions Typeface Screen Output Summary Review Questions Programming Exercise

6 CONTENTS v CHAPTER 2: Introducing C A Simple Sample of C The Explanation Pass 1 Quick Synopsis Pass 2 Details The Structure of a Simple Program Tips on Making Your Programs Readable Taking Another Step Documentation Multiple Declarations Multiplication Printing Multiple Values While You re at It Multiple Functions Debugging Syntax Errors Semantic Errors Program State Keywords and Reserved Identifiers Key Concepts Summary Review Questions Programming Exercises CHAPTER 3: Data and C A Sample Program What s New in This Program? Data Variables and Constants Data: Data-Type Keywords Integer Versus Floating-Point Types The Integer The Floating-Point Number C Data Types The int Type Other Integer Types Using Characters: Type char The _Bool Type Portable Types: inttypes.h Types float, double, and long double Complex and Imaginary Types Other Types Type Sizes

7 vi C PRIMER PLUS Using Data Types Arguments and Pitfalls One More Example What Happens Flushing the Output Key Concepts Summary Review Questions Programming Exercises CHAPTER 4: Character Strings and Formatted Input/Output Introductory Program Character Strings: An Introduction Type char Arrays and the Null Character Using Strings The strlen() Function Constants and the C Preprocessor The const Modifier Manifest Constants on the Job Exploring and Exploiting printf() and scanf() The printf() Function Using printf() Conversion Specification Modifiers for printf() The Meaning of Conversion Using scanf() The * Modifier with printf() and scanf() Usage Tips Key Concepts Summary Review Questions Programming Exercises CHAPTER 5: Operators, Expressions, and Statements Introducing Loops Fundamental Operators Assignment Operator: = Addition Operator: Subtraction Operator: Sign Operators: and Multiplication Operator: * Division Operator: / Operator Precedence Precedence and the Order of Evaluation

8 CONTENTS vii Some Additional Operators The sizeof Operator and the size_t Type Modulus Operator: % Increment and Decrement Operators: ++ and Decrementing: Precedence Don t Be Too Clever Expressions and Statements Expressions Statements Compound Statements (Blocks) Type Conversions The Cast Operator Function with Arguments A Sample Program Key Concepts Summary Review Questions Programming Exercises CHAPTER 6: C Control Statements: Looping An Initial Example Program Comments C-Style Reading Loop The while Statement Terminating a while Loop When a Loop Terminates while: An Entry-Condition Loop Syntax Points Which Is Bigger: Using Relational Operators and Expressions What Is Truth? What Else Is True? Troubles with Truth The New _Bool Type Precedence of Relational Operators Indefinite Loops and Counting Loops The for Loop Using for for Flexibility More Assignment Operators: +=, -=, *=, /=, %= The Comma Operator Zeno Meets the for Loop

9 viii C PRIMER PLUS An Exit-Condition Loop: do while Which Loop? Nested Loops Program Discussion A Nested Variation Arrays Using a for Loop with an Array A Loop Example Using a Function Return Value Program Discussion Using Functions with Return Values Key Concepts Summary Review Questions Programming Exercises CHAPTER 7: C Control Statements: Branching and Jumps The if Statement Adding else to the if Statement Another Example: Introducing getchar() and putchar() The ctype.h Family of Character Functions Multiple Choice else if Pairing else with if More Nested ifs Let s Get Logical Alternate Spellings: the iso646.h header file Precedence Order of Evaluation Ranges A Word-Count Program The Conditional Operator:? Loop Aids: continue and break The continue Statement The break Statement Multiple Choice: switch and break Using the switch Statement Reading Only the First Character of a Line Multiple Labels switch and if else The goto Statement Avoiding goto

10 CONTENTS ix Key Concepts Summary Review Questions Programming Exercises CHAPTER 8: Character Input/Output and Input Validation Single-Character I/O: getchar() and putchar() Buffers Terminating Keyboard Input Files, Streams, and Keyboard Input The End of File Redirection and Files Unix, Linux, and DOS Redirection Creating a Friendlier User Interface Working with Buffered Input Mixing Numeric and Character Input Input Validation Analyzing the Program The Input Stream and Numbers Menu Browsing Tasks Toward a Smoother Execution Mixing Character and Numeric Input Key Concepts Summary Review Questions Programming Exercises CHAPTER 9: Functions Reviewing Functions Creating and Using a Simple Function Analyzing the Program Function Arguments Defining a Function with an Argument: Formal Parameters Prototyping a Function with Arguments Calling a Function with an Argument: Actual Arguments The Black Box Viewpoint Returning a Value from a Function with return Function Types ANSI C Function Prototyping The Problem The ANSI Solution

11 x C PRIMER PLUS No Arguments and Unspecified Arguments Hooray for Prototypes Recursion Recursion Revealed Recursion Fundamentals Tail Recursion Recursion and Reversal Recursion Pros and Cons All C Functions Are Created Equal Compiling Programs with Two or More Source Code Files UNIX Linux DOS Command-Line Compilers Windows and Macintosh Compilers Using Header Files Finding Addresses: The & Operator Altering Variables in the Calling Function Pointers: A First Look The Indirection Operator: * Declaring Pointers Using Pointers to Communicate Between Functions Key Concepts Summary Review Questions Programming Exercises CHAPTER 10: Arrays and Pointers Arrays Initialization Designated Initializers (C99) Assigning Array Values Array Bounds Specifying an Array Size Multidimensional Arrays Initializing a Two-Dimensional Array More Dimensions Pointers and Arrays Functions, Arrays, and Pointers Using Pointer Arguments Comment: Pointers and Arrays Pointer Operations

12 CONTENTS xi Protecting Array Contents Using const with Formal Parameters More About const Pointers and Multidimensional Arrays Pointers to Multi-Dimensional Arrays Pointer Compatibility Functions and Multidimensional Arrays Variable-Length Arrays (VLAs) Compound Literals Key Concepts Summary Review Questions Programming Exercises CHAPTER 11: Character Strings and String Functions Defining Strings Within a Program Character String Constants (String Literals) Character String Arrays and Initialization Array Versus Pointer Arrays of Character Strings Pointers and Strings String Input Creating Space The gets() Function The fgets() Function The scanf() Function String Output The puts() Function The fputs() Function The printf() Function The Do-It-Yourself Option String Functions The strlen() Function The strcat() and strncat() Functions The strcmp() and strncmp() Functions The strcpy() and strncpy() Functions The sprintf() Function Other String Functions A String Example: Sorting Strings Sorting The ctype.h Character Functions and Strings

13 xii C PRIMER PLUS Command-Line Arguments Command-Line Arguments in Integrated Environments Command-Line Arguments with the Macintosh String to Number Conversions Key Concepts Summary Review Questions Programming Exercises CHAPTER 12: Storage Classes, Linkage, and Memory Management Storage Classes Scope Linkage Storage Duration Automatic Variables Register Variables Static Variables with Block Scope Static Variables with External Linkage Static Variables with Internal Linkage Multiple Files Storage-Class Specifiers Storage Classes and Functions Which Storage Class? A Random Number Function and a Static Variable Roll Em Allocated Memory: malloc() and free() The Importance of free() The calloc() Function Dynamic Memory Allocation and Variable-Length Arrays Storage Classes and Dynamic Memory Allocation ANSI C Type Qualifiers The const Type Qualifier The volatile Type Qualifier The restrict Type Qualifier New Places for Old Keywords Key Concepts Summary Review Questions Programming Exercises

14 CONTENTS xiii CHAPTER 13: File Input/Output Communicating with Files What Is a File? Levels of I/O Standard Files Standard I/O Checking for Command-Line Arguments The fopen() Function The getc() and putc() Functions End of File The fclose() Function Standard Files A Simple-Minded File-Condensing Program File I/O: fprintf(), fscanf(), fgets(), and fputs() The fprintf() and fscanf() Functions The fgets() and fputs() Functions Adventures in Random Access: fseek() and ftell() How fseek() and ftell() Work Binary Versus Text Mode Portability The fgetpos() and fsetpos() Functions Behind the Scenes with Standard I/O Other Standard I/O Functions The int ungetc(int c, FILE *fp) Function The int fflush(file *fp) Function The int setvbuf(file *fp, char *buf, int mode, size_t size) Function Binary I/O: fread() and fwrite() The size_t fwrite(void *ptr, size_t size, size_t nmemb, FILE *fp) Function The size_t fread(void *ptr, size_t size, size_t nmemb, FILE *fp) Function The int feof(file *fp) and int ferror(file *fp) Functions An Example Random Access with Binary I/O Key Concepts Summary Review Questions Programming Exercises CHAPTER 14: Structures and Other Data Forms Sample Problem: Creating an Inventory of Books Setting Up the Structure Declaration

15 xiv C PRIMER PLUS Defining a Structure Variable Initializing a Structure Designated Initializers for Structures Gaining Access to Structure Members Arrays of Structures Declaring an Array of Structures Identifying Members of an Array of Structures Program Discussion Nested Structures Pointers to Structures Declaring and Initializing a Structure Pointer Member Access by Pointer Telling Functions About Structures Passing Structure Members Using the Structure Address Passing a Structure as an Argument More on Structure Features Structures or Pointer to Structures? Character Arrays or Character Pointers in a Structure Structure, Pointers, and malloc() Compound Literals and Structures (C99) Flexible Array Members (C99) Functions Using an Array of Structures Saving the Structure Contents in a File Program Points Structures: What Next? Unions: A Quick Look Enumerated Types enum Constants Default Values Assigned Values Usage Shared Namespaces typedef: A Quick Look Fancy Declarations Functions and Pointers Key Concepts Summary Review Questions Programming Exercises

16 CONTENTS xv CHAPTER 15: Bit Fiddling Binary Numbers, Bits, and Bytes Binary Integers Signed Integers Binary Floating Point Other Bases Octal Hexadecimal C s Bitwise Operators Bitwise Logical Operators Usage: Masks Usage: Turning Bits On Usage: Turning Bits Off Usage: Toggling Bits Usage: Checking the Value of a Bit Bitwise Shift Operators Programming Example Another Example Bit Fields Bit-Field Example Bit Fields and Bitwise Operators Key Concepts Summary Review Questions Programming Exercises CHAPTER 16: The C Preprocessor and the C Library First Steps Manifest Constants: #define Tokens Redefining Constants Using Arguments with #define Creating Strings from Macro Arguments: The # Operator Preprocessor Glue: the ## Operator Variadic Macros:... and VA_ARGS Macro or Function? File Inclusion: #include Header Files: An Example Uses for Header Files

17 xvi C PRIMER PLUS Other Directives The #undef Directive Being Defined the C Preprocessor Perspective Conditional Compilation Predefined Macros #line and #error #pragma Inline Functions The C Library Gaining Access to the C Library Using the Library Descriptions The Math Library The General Utilities Library The exit() and atexit() Functions The qsort() Function The Assert Library memcpy() and memmove() from the string.h Library Variable Arguments: stdarg.h Key Concepts Summary Review Questions Programming Exercises CHAPTER 17: Advanced Data Representation Exploring Data Representation Beyond the Array to the Linked List Using a Linked List Afterthoughts Abstract Data Types (ADTs) Getting Abstract Building an Interface Using the Interface Implementing the Interface Getting Queued with an ADT Implementing the Interface Data Representation Testing the Queue Simulating with a Queue The Linked List Versus the Array Binary Search Trees A Binary Tree ADT The Binary Search Tree Interface The Binary Tree Implementation

18 CONTENTS xvii Trying the Tree Tree Thoughts Other Directions Key Concepts Summary Review Questions Programming Exercises APPENDIX A: Answers to the Review Questions hapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter Chapter APPENDIX B: Reference Section Section I Additional Reading Magazine Online Resources C Language Books Programming Reference C++ Books Section II C Operators Arithmetic Operators Relational Operators Assignment Operators Logical Operators The Conditional Operator Pointer-Related Operators

19 xviii C PRIMER PLUS Sign Operators Structure and Union Operators Bitwise Operators Miscellaneous Operators Section III Basic Types and Storage Classes Summary: The Basic Data Types Summary: How to Declare a Simple Variable Summary: Qualifiers Section IV Expressions, Statements, and Program Flow Summary: Expressions and Statements Summary: The while Statement Summary: The for Statement Summary: The do while Statement Summary: Using if Statements for Making Choices Summary: Multiple Choice with switch Summary: Program Jumps Section V The Standard ANSI C Library with C99 Additions Diagnostics: assert.h Complex Numbers: complex.h (C99) Character Handling: ctype.h Error Reporting: errno.h Floating-Point Environment: fenv.h (C99) Format Conversion of Integer Types: inttypes.h (C99) Localization: locale.h Math Library: math.h Non-Local Jumps: setjmp.h Signal Handling: signal.h Variable Arguments: stdarg.h Boolean Support: stdbool.h (C99) Common Definitions: stddef.h Integer Types: stdint.h Standard I/O Library: stdio.h General Utilities: stdlib.h String Handling: string.h Type-Generic Math: tgmath.h (C99) Date and Time: time.h Extended Multibyte and Wide Character Utilities: wchar.h (C99) Wide Character Classification and Mapping Utilities: wctype.h (C99) Section VI Extended Integer Types Exact Width Types Minimum Width Types

20 CONTENTS xix Fastest Minimum Width Types Maximum Width Types Integers That Can Hold Pointer Values Extended Integer Constants Section VII Expanded Character Support Trigraph Sequences Digraphs Alternative Spellings: iso646.h Multibyte Characters Universal Character Names (UCNs) Wide Characters Wide Characters and Multibyte Characters Section VIII C99 Numeric Computational Enhancements The IEC Floating-Point Standard The fenv.h Header File The STDC FP_CONTRACT Pragma Additions to the math.h Library Support for Complex Numbers Section IX Differences Between C and C Function Prototypes char Constants The const Modifier Structures and Unions Enumerations Pointer to void Boolean Types Alternative Spellings Wide Character Support Complex Types Inline Functions C++ Doesn t Have It INDEX

21 PREFACE C was a relatively little-known language when the first edition of C Primer Plus was written in Since then, the language has boomed, and many people have learned C with the help of this book. In fact, over 500,000 people have purchased C Primer Plus throughout its various editions. With the emergence of a new standard for C, it s time for a 4 th edition. As with all the editions, my aim has been to create an introduction to C that is instructive, clear, and helpful. Approach and Goals My goal is for this book to serve as a friendly, easy-to-use, self-study guide. To accomplish that objective, C Primer Plus employs the following strategies: Programming concepts are explained, along with details of the C language; the book does not assume that you are a professional programmer. Many short, easily-typed examples illustrate just one or two concepts at a time, because learning by doing is one of the most effective ways to master new information. Figures and illustrations clarify concepts that are difficult to grasp in words alone. Highlight boxes summarize the main features of C for easy reference and review. Review questions and programming exercises at the end of each chapter allow you to test and improve your understanding of C. To gain the greatest benefit, you should take as active a role as possible in studying the topics in this book. Don t just read the examples, enter them into your system and try them. C is a very portable language, but you may find differences between how a program works on your system and how it works on ours. Experiment change part of a program to see what the effect is. Modify a program to do something slightly different. Ignore the occasional warnings and see what happens when you do the wrong thing. Try the questions and exercises. The more you do yourself, the more you will learn and remember. I hope that you ll find this newest edition an enjoyable and effective introduction to the C language. Changes in the 4 th Edition There is a new standard for the C language. It s called the ISO/IEC 9899:1999 International Standard, but among friends it often goes by the simpler name of C99. It was adopted by the International Organization for Standardization (ISO) and the International Electrotechnical

22 Committee (IEC) in 1999 and approved as the American standard by the American National Standards Institute (ANSI) in This new edition of C Primer Plus incorporates the new standard. Here are some of the new features covered: Extended integer types Expanded character support Boolean support Variable-length arrays Compound literals Designated initializers Expanded computational support Inline functions This edition also reorganizes the presentation of some topics. For example, the discussion of pointers in Chapter 10, Arrays and Pointers, has been consolidated and expanded, and Chapter 12, Storage Classes, Linkage, and Memory Management, incorporates dynamic memory allocation into the discussion of C storage classes and memory management. Numerous other changes and additions have been incorporated in response to reader requests to make this edition an even more effective learning tool.

23 ABOUT THE AUTHOR Stephen Prata is a professor of physics and astronomy at the College of Marin in Kentfield, California, where he teaches astronomy, physics, and programming. He received his B.S. from the California Institute of Technology and his Ph.D. from the University of California, Berkeley. His association with computers began with the computer modeling of star clusters. Stephen has authored or coauthored over a dozen books, including C++ Primer Plus and Unix Primer Plus.

24 DEDICATION With love to Vicky and Bill Prata, who, for more than 65 years, have been showing how rewarding a marriage can be. SP

The Waite Group's. New. Primer Plus. Second Edition. Mitchell Waite and Stephen Prata SAMS

The Waite Group's. New. Primer Plus. Second Edition. Mitchell Waite and Stephen Prata SAMS The Waite Group's New Primer Plus Second Edition Mitchell Waite and Stephen Prata SAMS PUBLISHING A Division of Prentice Hall Computer Publishing 11711 North College, Carmel, Indiana 46032 USA Contents

More information

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and #include The Use of printf() and scanf() The Use of printf()

More information

Contents. Preface. Introduction. Introduction to C Programming

Contents. Preface. Introduction. Introduction to C Programming c11fptoc.fm Page vii Saturday, March 23, 2013 4:15 PM Preface xv 1 Introduction 1 1.1 1.2 1.3 1.4 1.5 Introduction The C Programming Language C Standard Library C++ and Other C-Based Languages Typical

More information

C-LANGUAGE CURRICULAM

C-LANGUAGE CURRICULAM C-LANGUAGE CURRICULAM Duration: 2 Months. 1. Introducing C 1.1 History of C Origin Standardization C-Based Languages 1.2 Strengths and Weaknesses Of C Strengths Weaknesses Effective Use of C 2. C Fundamentals

More information

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...

More information

CSCI 171 Chapter Outlines

CSCI 171 Chapter Outlines Contents CSCI 171 Chapter 1 Overview... 2 CSCI 171 Chapter 2 Programming Components... 3 CSCI 171 Chapter 3 (Sections 1 4) Selection Structures... 5 CSCI 171 Chapter 3 (Sections 5 & 6) Iteration Structures

More information

This document is a preview generated by EVS

This document is a preview generated by EVS INTERNATIONAL STANDARD ISO/IEC 9899 Fourth edition 2018-07 Information technology Programming languages C Technologies de l'information Langages de programmation C Reference number ISO/IEC 9899:2018(E)

More information

C Programming SYLLABUS COVERAGE SYLLABUS IN DETAILS

C Programming SYLLABUS COVERAGE SYLLABUS IN DETAILS C Programming C SYLLABUS COVERAGE Introduction to Programming Fundamentals in C Operators and Expressions Data types Input-Output Library Functions Control statements Function Storage class Pointer Pointer

More information

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites: C Programming Code: MBD101 Duration: 10 Hours Prerequisites: You are a computer science Professional/ graduate student You can execute Linux/UNIX commands You know how to use a text-editing tool You should

More information

About Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals

More information

The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured

The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured Introduction p. xxix The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured Language p. 6 C Is a Programmer's Language

More information

Practical C++ Programming

Practical C++ Programming SECOND EDITION Practical C++ Programming Steve Oualline O'REILLY' Beijing Cambridge Farnham Koln Paris Sebastopol Taipei Tokyo Preface xv Part I. The Basics 1. What Is C++? 3 A Brief History of C++ 3 C++

More information

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are

More information

Holtek C and ANSI C Feature Comparison User s Guide

Holtek C and ANSI C Feature Comparison User s Guide Holtek C and ANSI C Feature Comparison User s Guide July 2009 Copyright 2009 by HOLTEK SEMICONDUCTOR INC. All rights reserved. Printed in Taiwan. No part of this publication may be reproduced, stored in

More information

File (1A) Young Won Lim 11/25/16

File (1A) Young Won Lim 11/25/16 File (1A) Copyright (c) 2010-2016 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version

More information

Aryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9

Aryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9 Fundamental of C Programming Unit I: Q1. What will be the value of the following expression? (2017) A + 9 Q2. Write down the C statement to calculate percentage where three subjects English, hindi, maths

More information

C: Pointers, Arrays, and strings. Department of Computer Science College of Engineering Boise State University. August 25, /36

C: Pointers, Arrays, and strings. Department of Computer Science College of Engineering Boise State University. August 25, /36 Department of Computer Science College of Engineering Boise State University August 25, 2017 1/36 Pointers and Arrays A pointer is a variable that stores the address of another variable. Pointers are similar

More information

Axivion Bauhaus Suite Technical Factsheet MISRA

Axivion Bauhaus Suite Technical Factsheet MISRA MISRA Contents 1. C... 2 1. Misra C 2004... 2 2. Misra C 2012 (including Amendment 1). 10 3. Misra C 2012 Directives... 18 2. C++... 19 4. Misra C++ 2008... 19 1 / 31 1. C 1. Misra C 2004 MISRA Rule Severity

More information

DETAILED SYLLABUS INTRODUCTION TO C LANGUAGE

DETAILED SYLLABUS INTRODUCTION TO C LANGUAGE COURSE TITLE C LANGUAGE DETAILED SYLLABUS SR.NO NAME OF CHAPTERS & DETAILS HOURS ALLOTTED 1 INTRODUCTION TO C LANGUAGE About C Language Advantages of C Language Disadvantages of C Language A Sample Program

More information

CODE TIME TECHNOLOGIES. Abassi RTOS MISRA-C:2004. Compliance Report

CODE TIME TECHNOLOGIES. Abassi RTOS MISRA-C:2004. Compliance Report CODE TIME TECHNOLOGIES Abassi RTOS MISRA-C:2004 Compliance Report Copyright Information This document is copyright Code Time Technologies Inc. 2012. All rights reserved. No part of this document may be

More information

Advanced C Programming Topics

Advanced C Programming Topics Introductory Medical Device Prototyping Advanced C Programming Topics, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota Operations on Bits 1. Recall there are 8

More information

Model Viva Questions for Programming in C lab

Model Viva Questions for Programming in C lab Model Viva Questions for Programming in C lab Title of the Practical: Assignment to prepare general algorithms and flow chart. Q1: What is a flowchart? A1: A flowchart is a diagram that shows a continuous

More information

Language Design COMS W4115. Prof. Stephen A. Edwards Spring 2003 Columbia University Department of Computer Science

Language Design COMS W4115. Prof. Stephen A. Edwards Spring 2003 Columbia University Department of Computer Science Language Design COMS W4115 Prof. Stephen A. Edwards Spring 2003 Columbia University Department of Computer Science Language Design Issues Syntax: how programs look Names and reserved words Instruction

More information

MISRA-C:2012 Standards Model Summary for C / C++

MISRA-C:2012 Standards Model Summary for C / C++ Version 9.7.1 Copyright 2017 Ltd. MISRA-C:2012 s Model Summary for C / C++ The tool suite is developed and certified to BS EN ISO 9001:2000 and SGS-TÜV Saar. This information is applicable to version 9.7.1

More information

C mini reference. 5 Binary numbers 12

C mini reference. 5 Binary numbers 12 C mini reference Contents 1 Input/Output: stdio.h 2 1.1 int printf ( const char * format,... );......................... 2 1.2 int scanf ( const char * format,... );.......................... 2 1.3 char

More information

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University Fundamental Data Types CSE 130: Introduction to Programming in C Stony Brook University Program Organization in C The C System C consists of several parts: The C language The preprocessor The compiler

More information

Systems Programming. 08. Standard I/O Library. Alexander Holupirek

Systems Programming. 08. Standard I/O Library. Alexander Holupirek Systems Programming 08. Standard I/O Library Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science University of Konstanz Summer Term 2008 Last lecture:

More information

Course organization. Course introduction ( Week 1)

Course organization. Course introduction ( Week 1) Course organization Course introduction ( Week 1) Code editor: Emacs Part I: Introduction to C programming language (Week 2-9) Chapter 1: Overall Introduction (Week 1-3) Chapter 2: Types, operators and

More information

Review of the C Programming Language for Principles of Operating Systems

Review of the C Programming Language for Principles of Operating Systems Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights

More information

SOME ASSEMBLY REQUIRED

SOME ASSEMBLY REQUIRED SOME ASSEMBLY REQUIRED Assembly Language Programming with the AVR Microcontroller TIMOTHY S. MARGUSH CRC Press Taylor & Francis Group CRC Press is an imprint of the Taylor & Francis Croup an Informa business

More information

edunepal_info

edunepal_info facebook.com/edunepal.info @ edunepal_info C interview questions (1 125) C interview questions are given with the answers in this website. We have given C interview questions faced by freshers and experienced

More information

Tokens, Expressions and Control Structures

Tokens, Expressions and Control Structures 3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

More information

Contents. A Review of C language. Visual C Visual C++ 6.0

Contents. A Review of C language. Visual C Visual C++ 6.0 A Review of C language C++ Object Oriented Programming Pei-yih Ting NTOU CS Modified from www.cse.cuhk.edu.hk/~csc2520/tuto/csc2520_tuto01.ppt 1 2 3 4 5 6 7 8 9 10 Double click 11 12 Compile a single source

More information

HP C Language Reference Manual

HP C Language Reference Manual HP C Language Reference Manual Order Number: AA PUNDJ TK January 2005 This document is the language reference manual for HP C. Revision Update Information: Software Version: This manual supersedes the

More information

M1-R4: Programing and Problem Solving using C (JULY 2018)

M1-R4: Programing and Problem Solving using C (JULY 2018) M1-R4: Programing and Problem Solving using C (JULY 2018) Max Marks: 100 M1-R4-07-18 DURATION: 03 Hrs 1. Each question below gives a multiple choice of answers. Choose the most appropriate one and enter

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

XML Primer Plus By Nicholas Chase

XML Primer Plus By Nicholas Chase Table of Contents Index XML Primer Plus By Nicholas Chase Publisher : Sams Publishing Pub Date : December 16, 2002 ISBN : 0-672-32422-9 Pages : 1024 This book presents XML programming from a conceptual

More information

This is a preview - click here to buy the full publication INTERNATIONAL STANDARD. Programming languages - C. Langages de programmation - C

This is a preview - click here to buy the full publication INTERNATIONAL STANDARD. Programming languages - C. Langages de programmation - C INTERNATIONAL STANDARD ISOIIEC 9899 First edition 1990-12-15 Programming languages - C Langages de programmation - C E - w - E = z 2 z 3 = = = = - = s E- E Z C - Reference number ISOAEC 9899 : 1990 (El

More information

UNIT I : OVERVIEW OF COMPUTERS AND C-PROGRAMMING

UNIT I : OVERVIEW OF COMPUTERS AND C-PROGRAMMING SIDDARTHA INSTITUTE OF SCIENCE AND TECHNOLOGY:: PUTTUR Siddharth Nagar, Narayanavanam Road 517583 QUESTION BANK (DESCRIPTIVE) Subject with Code : PROGRAMMING FOR PROBLEM SOLVING (18CS0501) Course & Branch

More information

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 4

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 4 BIL 104E Introduction to Scientific and Engineering Computing Lecture 4 Introduction Divide and Conquer Construct a program from smaller pieces or components These smaller pieces are called modules Functions

More information

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object CHAPTER 1 Introduction to Computers and Programming 1 1.1 Why Program? 1 1.2 Computer Systems: Hardware and Software 2 1.3 Programs and Programming Languages 8 1.4 What is a Program Made of? 14 1.5 Input,

More information

VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANGULATHUR

VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANGULATHUR VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANGULATHUR 603 203 FIRST SEMESTER B.E / B.Tech., (Common to all Branches) QUESTION BANK - GE 6151 COMPUTER PROGRAMMING UNIT I - INTRODUCTION Generation and

More information

Problem Solving with C++

Problem Solving with C++ GLOBAL EDITION Problem Solving with C++ NINTH EDITION Walter Savitch Kendrick Mock Ninth Edition PROBLEM SOLVING with C++ Problem Solving with C++, Global Edition Cover Title Copyright Contents Chapter

More information

Motor Industry Software Reliability Association (MISRA) C:2012 Standard Mapping of MISRA C:2012 items to Goanna checks

Motor Industry Software Reliability Association (MISRA) C:2012 Standard Mapping of MISRA C:2012 items to Goanna checks Goanna 3.3.2 Standards Data Sheet for MISRA C:2012 misrac2012-datasheet.pdf Motor Industry Software Reliability Association (MISRA) C:2012 Standard Mapping of MISRA C:2012 items to Goanna checks The following

More information

C Programming for Electronic Engineers

C Programming for Electronic Engineers C Programming for Electronic Engineers Keith Jackson BSc CEng MIEE with acknowledgement to Gavin Eamshaw MEng School of Electronic, Communication and Electrical Engineering University of Plymouth MACMILLAN

More information

Language Design COMS W4115. Prof. Stephen A. Edwards Fall 2006 Columbia University Department of Computer Science

Language Design COMS W4115. Prof. Stephen A. Edwards Fall 2006 Columbia University Department of Computer Science Language Design COMS W4115 Katsushika Hokusai, In the Hollow of a Wave off the Coast at Kanagawa, 1827 Prof. Stephen A. Edwards Fall 2006 Columbia University Department of Computer Science Language Design

More information

Appendix A Developing a C Program on the UNIX system

Appendix A Developing a C Program on the UNIX system Appendix A Developing a C Program on the UNIX system 1. Key in and save the program using vi - see Appendix B - (or some other editor) - ensure that you give the program file a name ending with.c - to

More information

Review of the C Programming Language

Review of the C Programming Language Review of the C Programming Language Prof. James L. Frankel Harvard University Version of 11:55 AM 22-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reference Manual for the

More information

File I/O. Preprocessor Macros

File I/O. Preprocessor Macros Computer Programming File I/O. Preprocessor Macros Marius Minea marius@cs.upt.ro 4 December 2017 Files and streams A file is a data resource on persistent storage (e.g. disk). File contents are typically

More information

advanced data types (2) typedef. today advanced data types (3) enum. mon 23 sep 2002 defining your own types using typedef

advanced data types (2) typedef. today advanced data types (3) enum. mon 23 sep 2002 defining your own types using typedef today advanced data types (1) typedef. mon 23 sep 2002 homework #1 due today homework #2 out today quiz #1 next class 30-45 minutes long one page of notes topics: C advanced data types dynamic memory allocation

More information

ANSI C Changes. Jonathan Hoyle Eastman Kodak 10/5/00

ANSI C Changes. Jonathan Hoyle Eastman Kodak 10/5/00 ANSI C Changes Jonathan Hoyle Eastman Kodak 10/5/00 ANSI C Changes Introduction Changes to C in conformance to C++ New additions to C friendly to C++ New additions to C unfriendly to C++ What has not changed

More information

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p. Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p. 9 Self-Test Exercises p. 11 History Note p. 12 Programming and

More information

C: Arrays, and strings. Department of Computer Science College of Engineering Boise State University. September 11, /16

C: Arrays, and strings. Department of Computer Science College of Engineering Boise State University. September 11, /16 Department of Computer Science College of Engineering Boise State University September 11, 2017 1/16 1-dimensional Arrays Arrays can be statically declared in C, such as: int A [100]; The space for this

More information

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language 1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC

More information

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things. A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators

More information

Course Title: C Programming Full Marks: Course no: CSC110 Pass Marks: Nature of course: Theory + Lab Credit hours: 3

Course Title: C Programming Full Marks: Course no: CSC110 Pass Marks: Nature of course: Theory + Lab Credit hours: 3 Detailed Syllabus : Course Title: C Programming Full Marks: 60+20+20 Course no: CSC110 Pass Marks: 24+8+8 Nature of course: Theory + Lab Credit hours: 3 Course Description: This course covers the concepts

More information

I BCA[ ] SEMESTER I CORE: C PROGRAMMING - 106A Multiple Choice Questions.

I BCA[ ] SEMESTER I CORE: C PROGRAMMING - 106A Multiple Choice Questions. 1 of 22 8/4/2018, 4:03 PM Dr.G.R.Damodaran College of Science (Autonomous, affiliated to the Bharathiar University, recognized by the UGC)Reaccredited at the 'A' Grade Level by the NAAC and ISO 9001:2008

More information

EECS2031. Modifiers. Data Types. Lecture 2 Data types. signed (unsigned) int long int long long int int may be omitted sizeof()

EECS2031. Modifiers. Data Types. Lecture 2 Data types. signed (unsigned) int long int long long int int may be omitted sizeof() Warning: These notes are not complete, it is a Skelton that will be modified/add-to in the class. If you want to us them for studying, either attend the class or get the completed notes from someone who

More information

PERIYAR CENTENARY POLYTECHNIC COLLEGE Periyar Nagar- Vallam Thanjavur

PERIYAR CENTENARY POLYTECHNIC COLLEGE Periyar Nagar- Vallam Thanjavur PERIYAR CENTENARY POLYTECHNIC COLLEGE Periyar Nagar- Vallam-613 403 Thanjavur 01. Define program? 02. What is program development cycle? 03. What is a programming language? 04. Define algorithm? 05. What

More information

C Libraries. Bart Childs Complementary to the text(s)

C Libraries. Bart Childs Complementary to the text(s) C Libraries Bart Childs Complementary to the text(s) 2006 C was designed to make extensive use of a number of libraries. A great reference for student purposes is appendix B of the K&R book. This list

More information

Appendices E through H are PDF documents posted online at the book s Companion Website (located at

Appendices E through H are PDF documents posted online at the book s Companion Website (located at chtp7_printonlytoc.fm Page vii Monday, January 23, 2012 1:30 PM Appendices E through H are PDF documents posted online at the book s Companion Website (located at www.pearsonhighered.com/deitel). Preface

More information

Programming. C++ Basics

Programming. C++ Basics Programming C++ Basics Introduction to C++ C is a programming language developed in the 1970s with the UNIX operating system C programs are efficient and portable across different hardware platforms C++

More information

This lists all known errors in The C Programming Language, Second Edition, by Brian Kernighan and Dennis Ritchie (Prentice-Hall, 1988).

This lists all known errors in The C Programming Language, Second Edition, by Brian Kernighan and Dennis Ritchie (Prentice-Hall, 1988). Errata for The C Programming Language, Second Edition This lists all known errors in The C Programming Language, Second Edition, by Brian Kernighan and Dennis Ritchie (Prentice-Hall, 1988). The pagination

More information

Chapter 15 - C++ As A "Better C"

Chapter 15 - C++ As A Better C Chapter 15 - C++ As A "Better C" Outline 15.1 Introduction 15.2 C++ 15.3 A Simple Program: Adding Two Integers 15.4 C++ Standard Library 15.5 Header Files 15.6 Inline Functions 15.7 References and Reference

More information

Euclid s algorithm, 133

Euclid s algorithm, 133 Index A Algorithm computer instructions, 4 data and variables, 5 develop algorithm, 6 American Standard Code for Information Interchange (ASCII) codes, 141 definition, 142 features, 142 Arithmetic expressions

More information

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING UNIT-1

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING UNIT-1 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Year & Semester : I / II Section : CSE - 1 & 2 Subject Code : CS6202 Subject Name : Programming and Data Structures-I Degree & Branch : B.E C.S.E. 2 MARK

More information

UNIT IV-2. The I/O library functions can be classified into two broad categories:

UNIT IV-2. The I/O library functions can be classified into two broad categories: UNIT IV-2 6.0 INTRODUCTION Reading, processing and writing of data are the three essential functions of a computer program. Most programs take some data as input and display the processed data, often known

More information

Welcome to Teach Yourself Acknowledgments Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p.

Welcome to Teach Yourself Acknowledgments Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p. Welcome to Teach Yourself p. viii Acknowledgments p. xv Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p. 6 Standard C++: A Programming Language and a Library p. 8

More information

Programming in C. Part 1: Introduction

Programming in C. Part 1: Introduction Programming in C Part 1: Introduction Resources: 1. Stanford CS Education Library URL: http://cslibrary.stanford.edu/101/ 2. Programming in ANSI C, E Balaguruswamy, Tata McGraw-Hill PROGRAMMING IN C A

More information

Chapter 2 Basic Elements of C++

Chapter 2 Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 2-1 Chapter 2 Basic Elements of C++ At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion

More information

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are: LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words

More information

Computer Programming C++ (wg) CCOs

Computer Programming C++ (wg) CCOs Computer Programming C++ (wg) CCOs I. The student will analyze the different systems, and languages of the computer. (SM 1.4, 3.1, 3.4, 3.6) II. The student will write, compile, link and run a simple C++

More information

Chapter 14 - Advanced C Topics

Chapter 14 - Advanced C Topics Chapter 14 - Advanced C Topics Outline 14.1 Introduction 14.2 Redirecting Input/Output on UNIX and DOS Systems 14.3 Variable-Length Argument Lists 14.4 Using Command-Line Arguments 14.5 Notes on Compiling

More information

Contents. 1 Introduction to Computers, the Internet and the World Wide Web 1. 2 Introduction to C Programming 26

Contents. 1 Introduction to Computers, the Internet and the World Wide Web 1. 2 Introduction to C Programming 26 Preface xix 1 Introduction to Computers, the Internet and the World Wide Web 1 1.1 Introduction 2 1.2 What Is a Computer? 4 1.3 Computer Organization 4 1.4 Evolution of Operating Systems 5 1.5 Personal,

More information

C Refresher, Advance C, Coding Standard, Misra C Compliance & Real-time Programming

C Refresher, Advance C, Coding Standard, Misra C Compliance & Real-time Programming C Refresher, Advance C, Coding Standard, Misra C Compliance & Real-time Programming Course Overview This course transforms an IT-Professional or a Student into an expert C Programming Person with concepts

More information

Model Viva Questions for Programming in C lab

Model Viva Questions for Programming in C lab Model Viva Questions for Programming in C lab Common to: CSE 2 nd sem IT 2 nd sem Title of the Practical: Assignment to prepare general algorithms and flow chart. Q1: What is a flowchart? A1: A flowchart

More information

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9 Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits

More information

Review: Constants. Modules and Interfaces. Modules. Clients, Interfaces, Implementations. Client. Interface. Implementation

Review: Constants. Modules and Interfaces. Modules. Clients, Interfaces, Implementations. Client. Interface. Implementation Review: Constants Modules and s CS 217 C has several ways to define a constant Use #define #define MAX_VALUE 10000 Substitution by preprocessing (will talk about this later) Use const const double x =

More information

CS6202 - PROGRAMMING & DATA STRUCTURES UNIT I Part - A 1. W hat are Keywords? Keywords are certain reserved words that have standard and pre-defined meaning in C. These keywords can be used only for their

More information

IECD Institute for Entrepreneurship and Career Development Bharathidasan University, Tiruchirappalli 23.

IECD Institute for Entrepreneurship and Career Development Bharathidasan University, Tiruchirappalli 23. Subject code - CCP01 Chapt Chapter 1 INTRODUCTION TO C 1. A group of software developed for certain purpose are referred as ---- a. Program b. Variable c. Software d. Data 2. Software is classified into

More information

UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

More information

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary GATE- 2016-17 Postal Correspondence 1 C-Programming Computer Science & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key concepts, Analysis

More information

C Programming Multiple. Choice

C Programming Multiple. Choice C Programming Multiple Choice Questions 1.) Developer of C language is. a.) Dennis Richie c.) Bill Gates b.) Ken Thompson d.) Peter Norton 2.) C language developed in. a.) 1970 c.) 1976 b.) 1972 d.) 1980

More information

Other C materials before pointer Common library functions [Appendix of K&R] 2D array, string manipulations. <stdlib.

Other C materials before pointer Common library functions [Appendix of K&R] 2D array, string manipulations. <stdlib. 1 The previous lecture Other C materials before pointer Common library functions [Appendix of K&R] 2D array, string manipulations Pointer basics 1 Common library functions [Appendix of K+R]

More information

Quick review of previous lecture Ch6 Structure Ch7 I/O. EECS2031 Software Tools. C - Structures, Unions, Enums & Typedef (K&R Ch.

Quick review of previous lecture Ch6 Structure Ch7 I/O. EECS2031 Software Tools. C - Structures, Unions, Enums & Typedef (K&R Ch. 1 Quick review of previous lecture Ch6 Structure Ch7 I/O EECS2031 Software Tools C - Structures, Unions, Enums & Typedef (K&R Ch.6) Structures Basics: Declaration and assignment Structures and functions

More information

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17 List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code

More information

Introduction to C++ with content from

Introduction to C++ with content from Introduction to C++ with content from www.cplusplus.com 2 Introduction C++ widely-used general-purpose programming language procedural and object-oriented support strong support created by Bjarne Stroustrup

More information

Practical C Programming. Steve Oualline

Practical C Programming. Steve Oualline Practical C Programming Steve Oualline Preface Scope of This Handbook Conventions Used in This Handbook Acknowledgments xviii xix xx i xxii Chapter 1 The Basics of Program Writing 1 Text Editor 2 Compiler

More information

Input / Output Functions

Input / Output Functions CSE 2421: Systems I Low-Level Programming and Computer Organization Input / Output Functions Presentation G Read/Study: Reek Chapter 15 Gojko Babić 10-03-2018 Input and Output Functions The stdio.h contain

More information

Computers Programming Course 5. Iulian Năstac

Computers Programming Course 5. Iulian Năstac Computers Programming Course 5 Iulian Năstac Recap from previous course Classification of the programming languages High level (Ada, Pascal, Fortran, etc.) programming languages with strong abstraction

More information

CSE2301. Functions. Functions and Compiler Directives

CSE2301. Functions. Functions and Compiler Directives Warning: These notes are not complete, it is a Skelton that will be modified/add-to in the class. If you want to us them for studying, either attend the class or get the completed notes from someone who

More information

Dr M Kasim A Jalil. Faculty of Mechanical Engineering UTM (source: Deitel Associates & Pearson)

Dr M Kasim A Jalil. Faculty of Mechanical Engineering UTM (source: Deitel Associates & Pearson) Lecture 9 Functions Dr M Kasim A Jalil Faculty of Mechanical Engineering UTM (source: Deitel Associates & Pearson) Objectives In this chapter, you will learn: To understand how to construct programs modularly

More information

M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be

More information

ECE 2400 Computer Systems Programming Fall 2017 Topic 12: Transition from C to C++

ECE 2400 Computer Systems Programming Fall 2017 Topic 12: Transition from C to C++ ECE 2400 Computer Systems Programming Fall 2017 Topic 12: Transition from C to C++ School of Electrical and Computer Engineering Cornell University revision: 2017-10-23-01-13 1 C++ Namespaces 2 2 C++ Functions

More information

CSci 4061 Introduction to Operating Systems. Input/Output: High-level

CSci 4061 Introduction to Operating Systems. Input/Output: High-level CSci 4061 Introduction to Operating Systems Input/Output: High-level I/O Topics First, cover high-level I/O Next, talk about low-level device I/O I/O not part of the C language! High-level I/O Hide device

More information

MPATE-GE 2618: C Programming for Music Technology. Syllabus

MPATE-GE 2618: C Programming for Music Technology. Syllabus MPATE-GE 2618: C Programming for Music Technology Instructor Dr. Schuyler Quackenbush schuyler.quackenbush@nyu.edu Lab Teaching Assistant TBD Description Syllabus MPATE-GE 2618: C Programming for Music

More information

C: Pointers. C: Pointers. Department of Computer Science College of Engineering Boise State University. September 11, /21

C: Pointers. C: Pointers. Department of Computer Science College of Engineering Boise State University. September 11, /21 Department of Computer Science College of Engineering Boise State University September 11, 2017 1/21 Pointers A pointer is a variable that stores the address of another variable. Pointers are similar to

More information

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types Lecture 03 Bits, Bytes and Data Types Computer Languages A computer language is a language that is used to communicate with a machine. Like all languages, computer languages have syntax (form) and semantics

More information

Programming in C and C++

Programming in C and C++ Programming in C and C++ 1. Types Variables Expressions & Statements Dr. Anil Madhavapeddy University of Cambridge (based on previous years thanks to Alan Mycroft, Alastair Beresford and Andrew Moore)

More information