0% found this document useful (0 votes)
595 views4 pages

Chapter 2 Overview of C

This document contains a true/false quiz and multiple choice questions about the C programming language. Some key points: - C was developed by Dennis Ritchie. - A data type is a set of values and operations on those values. - Text enclosed in /* and */ comments in a C program and is ignored by the C compiler. - A C compiler can detect syntax errors, run-time errors, and arithmetic faults. - An interactive program uses prompting messages to direct user input.

Uploaded by

Rohit Bathla
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
595 views4 pages

Chapter 2 Overview of C

This document contains a true/false quiz and multiple choice questions about the C programming language. Some key points: - C was developed by Dennis Ritchie. - A data type is a set of values and operations on those values. - Text enclosed in /* and */ comments in a C program and is ignored by the C compiler. - A C compiler can detect syntax errors, run-time errors, and arithmetic faults. - An interactive program uses prompting messages to direct user input.

Uploaded by

Rohit Bathla
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Chapter 2

True/False
1. 2. 3.

Overview of C
b + c = a; [False] [True]

This assignment statement stores the sum of b and c in a:

The word char is a reserved word in C so it cannot be used as a variable name. The directive #define FIVE 5 notifies the C preprocessor that it is to replace each use of FIVE by 5.

[True]

4.

All values stored in memory are represented as binary strings, patterns of zeros and ones. [True]

5.

The statement c = d; checks to see if variables c and d have the same value. [False]

6.

If x is a type double variable and n is of type int, the following assignment statements are equivalent. x = n; [True] x = (double)n;

7.

If the value of x is 735, the statement printf("%4d", x); will display four blanks followed by 735. [False]

8.

The value of the expression x + y * z * z is always the same as the value of x + ((y * z) * z) [True]

Multiple Choice
1. The constant 0.15e+6 represents the same value as __________. *a. b. c. d. e. 2. 150000.0 6.15 0.75 0.21 none of the above (The symbol '#' stands for one

What would be displayed by the following program? blank character.) int main(void) { double a, b; a = 37.56; b = 101.117;

printf("Is it%6.1f%9.4f", a, b); printf("?\n"); return (0); } a. *b. c. d. e. 3. Is#it##37.6#101.1170?\n Is#it##37.6#101.1170? Is#it##37.5#101.1170? Is#it##37.6#101.117?\n none of the above

Which of the following are valid identifiers? i. R3D3 iv. ice_cream a. *b. c. d. e. i, ii, iv, v i, iv i, ii ii, iv, v All are valid. ii. per-capita v. 92_aardvarks iii. phone#

4.

The programming language C was developed by __________. a. b. c. *d. e. John von Neumann John Atanasoff Niklaus Wirth Dennis Ritchie Guy Steele

5.

A _________ is a set of values and a set of operations on those values. a. *b. c. d. e. file data type precedence rule library language standard

6.

Which one of the following expressions does not evaluate to 3? a. *b. c. d. e. 2 + 16 % 5 7 - 15 / 4 6 * 5 / 10 2 - 4 * 3 + 26 / 2 8 - 5 */ in a C program _________.

7.

Text enclosed in /* a. b. c.

gives instructions to the processor declares memory requirements makes files available

d. *e. 8.

causes a syntax error is ignored by the C compiler

A C compiler detects ______. *a. b. c. d. e. syntax errors run-time errors result errors arithmetic faults all of the above

9.

A program that uses prompting messages to direct the user's input is running in ______. a. b. *c. d. e. batch mode arithmetic/logic mode interactive mode assembly language mode memory mode 5 + 6.6 / 2.2 * 0.5 is [6.5].

1. 2.

The value of the expression

If the type int variable a and the type double variables b and c have values 403, 201.447, and -11.2 respectively, write a single statement that will display the following line of output (for clarity, a '#' is used to indicate one space). ##403#####201.45####-11.200 [One answer: printf("%5d%11.2f%11.3f\n", a, b, c);]

3.

Write a complete C program that prompts the user to enter the radius of a circle and displays the circumference. [Answer: #include <stdio.h> #define PI 3.14159 int main(void) { double radius, circum; printf("Please enter radius of circle> "); scanf("%lf", &radius); circum = 2 * PI * radius; printf("The circumference is %.2f.\n", circum); return (0); } ] Be sure to name the constant P.

4.

What happens to the fractional part of a type double expression when the expression is assigned to a type int variable? [Answer: The fractional part is lost.]

5.

Unary operators have [right] associativity; associativity.

binary operators have [left]

You might also like