Chapter 3: Review QuestionsΒΆ

1. What will the values of each variable be after the input
 command:

 data input: Tom 34678.2 AA4231

 scanf("%s %3d %f %c %*c %1d %x",name,&m,&x,&ch,&i,&j);

 name:________________________________________________
   m :________________________________________________
   x :________________________________________________
  ch :________________________________________________
   i :________________________________________________
   j :________________________________________________

2. What output does each of these produce?

 a) putchar('a');
________________________________

 b) putchar('\007');
________________________________

 c) putchar('\n');
________________________________

 d) putchar('\t');
________________________________

 e) n = 32; putchar(n);
________________________________

 f) putchar('\"');
________________________________

3. For the different values of n, what is the output?

 printf("%x %c %o %d",n,n,n,n);

 a) n = 67 ____________________________________________

 b) n = 20 ____________________________________________

 c) n = 128 ____________________________________________

 d) n = 255 ____________________________________________

 e) n = 100 ____________________________________________

4. What is wrong with each of these?

 a) scanf("%d",i);
 _______________________________________________________

 b) #include stdio.h
 _______________________________________________________

 c) putchar('/n');
 _______________________________________________________

 d) puts("\tHello");
 _______________________________________________________

 e) printf("\nPhone Number: (%s) %s",phone_number);
 _______________________________________________________

 f) getch(ch);
 _______________________________________________________

 g) putch() = ch;
 _______________________________________________________

 h) printf("\nEnter your name:",name);
 _______________________________________________________

5. Which numbering system is not handled directly
by the printf() conversion specifiers?

 a) decimal

 b) binary

 c) octal

 d) hexadecimal

6. The decimal 12 is the same as which one of the
following binary numbers?

 a) 1100

 b) 1010

 c) 1111

 d) 1110

7. The decimal number 12 is the same as which one of
the following octal numbers?

 a) 18

 b) 14

 c) 16

 d) 17

8. The decimal number 12 is the same as which one
of the following hexadecimal numbers?

 a) 0xa

 b) 0xb

 c) 0xc

 d) 0xd

9. Which one of the following conversion specifiers cannot be used for a number represented in binary form in the
computer?

 a) %b

 b) %d

 c) %o

 d) %x

10. Indicate which of the following declarations are valid (V) and which are invalid (I).

 a) ___ int count;
 b) ___ unsigned long int flag;
 c) ___ register int index;
 d) ___ extern long float budget;
 e) ___ signed short int i = 0;
 f) ___ const char c = '?';
 g) ___ static register long int q;
 h) ___ unsigned long int signed sum = 0;
 i) ___ long flag2 = 0xFF0000FF;
 j) ___ static unsigned short int hg;
 k) ___ extern double salary;
 l) ___ register unsigned long int ndx;
 m) ___ static const unsigned short weee;

Previous topic

Chapter 3: Programming Projects

Next topic

Chapter 4 Operators

This Page