Full file at C How to Program, 6/e Multiple Choice Test Bank

Similar documents
c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

Programming for Engineers Introduction to C

C: How to Program. Week /Mar/05

Chapter 2 - Introduction to C Programming

Introduction to C Programming. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

Introduction to C++ Programming Pearson Education, Inc. All rights reserved.

Chapter 2, Part I Introduction to C Programming

Fundamentals of Programming Session 4

Chapter 2, Part III Arithmetic Operators and Decision Making

Chapter 1 Introduction to Computers and C++ Programming

Fundamentals of Programming. Lecture 3: Introduction to C Programming

IT 374 C# and Applications/ IT695 C# Data Structures

Introduction to C# Applications

Introduction to Programming

Fundamental of Programming (C)

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

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

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

Chapter 1 & 2 Introduction to C Language

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

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

Introduction to C Programming

Chapter 2: Introduction to C++

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

Arithmetic Operators. Binary Arithmetic Operators. Arithmetic Operators. A Closer Look at the / Operator. A Closer Look at the % Operator

Chapter 2. Lexical Elements & Operators

ANSI C Programming Simple Programs

by Pearson Education, Inc. All Rights Reserved. 2

Programming and Data Structures

Intro to Computer Programming (ICP) Rab Nawaz Jadoon

Introduction to Java Applications; Input/Output and Operators

Università degli Studi di Bologna Facoltà di Ingegneria. Principles, Models, and Applications for Distributed Systems M

Introduction to C# Applications Pearson Education, Inc. All rights reserved.

LECTURE 02 INTRODUCTION TO C++

Data Types and Variables in C language

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

6.096 Introduction to C++ January (IAP) 2009

Computer Programming : C++

Basics of Java Programming

2.5 Another Application: Adding Integers

Lecture 2 Tao Wang 1

Introduction to C++ Programming. Adhi Harmoko S, M.Komp

UNIT IV 2 MARKS. ( Word to PDF Converter - Unregistered ) FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING

Creating a C++ Program

4. Inputting data or messages to a function is called passing data to the function.

Fundamentals of Programming

Unit 3. Operators. School of Science and Technology INTRODUCTION

Basic Elements of C. Staff Incharge: S.Sasirekha

Chapter 17. Fundamental Concepts Expressed in JavaScript

2/29/2016. Definition: Computer Program. A simple model of the computer. Example: Computer Program. Data types, variables, constants

Lecture 3 Tao Wang 1

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Typescript on LLVM Language Reference Manual

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

Introduction to Python Programming

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

Differentiate Between Keywords and Identifiers

.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar..

Chapter 2 Author Notes

DEPARTMENT OF MATHS, MJ COLLEGE

Data types, variables, constants

بسم اهلل الرمحن الرحيم

2.8. Decision Making: Equality and Relational Operators

BoredGames Language Reference Manual A Language for Board Games. Brandon Kessler (bpk2107) and Kristen Wise (kew2132)

CHAPTER 3 BASIC INSTRUCTION OF C++

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

BITG 1233: Introduction to C++

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

Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan

Chapter 2: Basic Elements of C++

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

Course Outline Introduction to C-Programming

Learning Language. Reference Manual. George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104)

9/5/2018. Overview. The C Programming Language. Transitioning to C from Python. Why C? Hello, world! Programming in C

UNIT- 3 Introduction to C++

Basics of Programming

The C Programming Language. (with material from Dr. Bin Ren, William & Mary Computer Science)

Preview from Notesale.co.uk Page 6 of 52

Program Elements -- Introduction

GraphQuil Language Reference Manual COMS W4115

Full file at

Course Outline. Introduction to java

CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING. Dr. Shady Yehia Elmashad

Professor: Sana Odeh Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators

Programming - 1. Computer Science Department 011COMP-3 لغة البرمجة 1 لطالب كلية الحاسب اآللي ونظم المعلومات 011 عال- 3

UEE1302 (1102) F10: Introduction to Computers and Programming

Language Reference Manual

VENTURE. Section 1. Lexical Elements. 1.1 Identifiers. 1.2 Keywords. 1.3 Literals

Objectives. In this chapter, you will:

INTRODUCTION 1 AND REVIEW

3. Except for strings, double quotes, identifiers, and keywords, C++ ignores all white space.

Chapter 2 Basic Elements of C++

2. Numbers In, Numbers Out

2 nd Week Lecture Notes

QUIZ: What value is stored in a after this

C - Basic Introduction

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead.

Overview: Programming Concepts. Programming Concepts. Names, Values, And Variables

Transcription:

2.1 Introduction 2.2 A Simple Program: Printing a Line of Text 2.1 Lines beginning with let the computer know that the rest of the line is a comment. (a) /* (b) ** (c) REM (d) << 2.2 Which of the following must every C program have? (a) main (b) #include (c) /* (d) <stdio.h> 2.3 Every statement in C must end with a (a) period (.) (b) semicolon (;) (c) colon (:) (d) backslash (/) 2.4 Which of the following is not a valid escape sequence? (a) \n (b) \\ (c) \~ (d) \ 2.5. Which statement about comments is false? a) Comments begin and end with /* and */, respectively. b) Programmers insert comments to document programs and improve program readability. c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

2.6. Lines beginning with a # are processed a) at execution time b) at compile time c) at preprocessor time d) at postprocessor time 2.7. Which of the following statements about the inclusion of <stdio.h> is false? a) It is required. b) This header file contains information and declarations used by the compiler when compiling standard input/output library functions such as printf. c) This header file contains information that helps the compiler determine if calls to library functions have been made correctly. d) This header helps locate bugs in your program at compile time, rather than at execution time (when errors are usually more costly to correct). 2.8. In the line int main() the parentheses indicate that main is a program building block called a a) module b) statement c) directive d) function 2.9. The pair of braces that delineate the body of main and the portion of the program between these braces is called a. a) function b) block c) statement d) header 2.10. Which of the following is not a synonym for a C string? a) message b) character string c) character d) literal

2.11. The following line is most properly an example of a. printf( Welcome to C! ); a) function b) block c) statement d) header 2.12. In a printf, a backslash is printed by enclosing in quotes a) \ b) \\ c) /\ d) // 2.13. A linked program is often called a(n). a) chain b) library c) object d) executable 2.14. The escape sequence for horizontal tab is. a) \t ab b) \t c) \horizontaltab d) \T 2.3 Another Simple Program: Adding Two Integers 2.15 Which of the following is not a valid integer value? (a) -3 (b) 0 (c) 2134859 (d) 1.1

2.16 Which of the following is an invalid identifier (variable name)? (a) _Test (b) TEST (c) 5test (d) test1 2.17 Which statement prints hi on the screen? (a) printf("hi"); (b) print "hi"; (c) printf "hi"; (d) none of the above 2.18 The sign is also known as the operator. (a) +, assignment (b) =, assignment (c) *, stream manipulator (d) &, stream insertion 2.19. A(n) is a location in the computer's memory where a value can be stored for use by a program. a) unknown b) name c) variable d) declaration 2.20. Which statement is false. a) Variables may be defined anywhere in the body of main. b) All variables must be defined. c) All variable definitions must include the name and data type of each variable. d) Several variable of the same data type may be defined in one definition. 2.21. Which of these is not a valid identifier? a) a_valid_identifier b) a1_valid_identifier c) a_valid_identifier_ d) 1_valid_identifier 2.22. Which of the following statements is false?

a) C is case sensitive. b) Uppercase and lowercase letters are different in C. c) identifier and IdEnTiFiEr are identical identifiers in C. d) Identifiers can be of any length 2.23. Which of the following multiple word variable names does not conform to the good programming practices in the text? a) multiple_word_variable_name b) multiplewordvariablename c) multiplewordvariablename d) areallyreallylongmultiplewordva 2.24. A(n) error is caused when the compiler can not recognize a statement. a) logic b) syntax c) linkage d) execution 2.25. The address operator is a) && b) % c) @ d) & 2.26. Which statement is false? a) in the statement sum = integer1 + integer2; both = and + are binary operators. b) The statement in part a) is an example of an assignment statement. c) The spaces around each of the binary operators in the statement of part a) are required. d) In part a), the = operator s two operands are sum and the value of the expression integer1 + integer2. 2.27. Which of the following is false? a) Each variable being input in a scanf statement is generally preceded by an &. b) Each variable being output in a printf statement is generally not preceded by an &. c) In a printf statement, the comma that separates the format control string from the

expressions to be printed is placed inside the format control string. d) Calculations can be performed inside printf statements. 2.4 Memory Concepts 2.28 Variable names actually correspond to. (a) locations in the computer's memory (b) operators (c) integers (d) data types 2.28 When a number gets assigned to a variable that already has a value. (a) the new number overwrites the previous value at that memory location (b) the new number gets assigned to a neighboring memory location (c) the computer issues an error (d) the new value is destroyed and the old value remains 2.30. Every variable has all the attributes below, except a) name b) value c) alias d) type 2.31. Which of the following is false? a) Reading a value into a memory location destroys the previous value. b) Reading a value out of a memory location destroys that value. c) sum = integer1 + integer2; involves destructive read-in. d) The statement in part c) also involves nondestructive read-out. 2.5 Arithmetic in C 2.32 Which operation will find the remainder when 15 is divided by 6? (a) 15 / 6 (b) 15 % 6 (c) 15 ^ 6

(d) 15 * 6 2.33 Evaluate the expression 3 * 4 % 6 + 4 *5 (a) 20 (b) 26 (c) 12 (d) 32 2.34. Which statement is false? a) In algebra, we write ab to multiply a times b. b) In C, we write ab to multiply a times b. c) In C, the remainder operator is %. d) In C, integer division yields an integer result. 2.35. Which statement about C arithmetic is false? a) 6 / 3 yields 2 b) 5 / 2 yields 2.5 c) 7 % 3 yields 1 d) 6 % 3 yields 0 2.36. a * (b + c) may also be written in C as a) ab + ac b) (a * b ) + c c) a * b + c d) a * b + a * c 2.37. Which statement about precedence is false? a) Parentheses may be used to force the order of evaluation to occur in any sequence desired by the programmer. b) Nested, or embedded parentheses are evaluated last. c) Multiplication has a higher precedence than addition. d) Subtraction has a lower precedence than division. 2.38. Which expression is true? a) The expression a * (b + c) + c * (d + e) contains nested parentheses. b) The expression y = a * x * x + b * x + c is a second degree polynomial. c) The C standard library provides function power to perform exponentiation.

d) When we say evaluation of an expression proceeds from left to right we are referring to the additivity of the operators. 2.6 Decision Making: Equality and Relational Operators 2.39 C's if statement executes the statement inside its body if a specified is. (a) condition, true (b) condition, false (c) equality operator, true (d) relational operator, true 2.40 Which of the following is an equality operator? (a) == (b) = (c) > (d) >= 2.41. Which statement is false? a) Executable C statements either perform actions or make decisions. b) If the condition in an if statement is met, the statement in the body of the if statement is executed. c) All the relational operators have the same level of precedence. d) The equality operators have a higher level of precedence than the relational operators. 2.42. Which statement is false? a) The relational operators associate left to right. b) An execution time error will occur if the two symbols in any of the operators ==,!=, >= and <= are separated by spaces. c) Confusing the == operator with = operator is typically an error. d) The equality operators associate left to right. 2.43. Which statement is false? a) Whitespace characters such as tabs, newlines and spaces are generally ignored by the C compiler. b) The statements in an if statement must be indented. c) Placing a blank line before and after every control structure can improve program

readability. d) There can be (but should not be) more than one statement per line. 2.44. Which statement is false? a) It is not correct to split an identifier with a space, a tab or a newline. b) Statements and comments may be split over several lines. c) The equals sign (=) is not an operator. d) A good programming practice is to break a line after a comma in a lengthy comma-separated list. 2.45. Which of the following is not a keyword? a) int b) return c) if d) main 2.46. Which statement is false? a) The assignment operator associates from left to right. b) The arithmetic operators associate from left to right. c) The equality operators associate from left to right. d) The relational operators associate from left to right. 2.47. The order in which statements are is called flow of control. a) entered in a source file b) preprocessed c) compiled d) executed 2.48. Which is not a keyword? a) register b) volatile c) external d) struct