The. C Declarations 37
SUMMARY
Having studied the basics in the first chapter the reader is now exposed in the second chapter to the
additional fundamentals of C. These things are absolutely essential for writing the programs. The
reader is made aware of the following points. Readers are suggested to go through this chapter
thoroughly as the chapter contains the fundamentals and basics.
a) Different types of characters like letters, digits, white space, and special characters. Various
delimiters used with C statements, keywords and identifiers.
b) Different constants, variables, and data types.
c) Rules for defining variables and initializing them.
d) Type conversion of variable.
e) Constant and volatile variables.
EXERCISES
A) Answer the following questions.
1) What are the different data types?
2) What are the differences between signed and unsigned data types?
3) What is meant by a variable and a constant?
4) Explain different types of constants in C.
5) What are the C keywords? Elaborate them.
6) List the rules for declaring a variable.
7) What are identifiers?
8) Explain the methods for initialization of variables.
9) Explain constants and volatile variables.
10) Write about space requirement for variables of different data types.
11) What are delimiters? Explain their uses.
12) Is main a keyword? Explain.
13) List any three keywords with their use.
14) What is the difference between %f and %g control strings? Can both be used for representing
float numbers?
15) What do you mean by type conversion? Why is it necessary?
B) Select the appropriate option fo r each o f the following questions.
1) A character variable can store only
a) 1 character
b)
20 characters
c) 254 characters
d)
none of the above
C variable cannot start with
a) a number
b)
an alphabet
c) a character
d)
none of the above
A short integer variable occupies memory
a) 2 bytes
b)
4 bytes
c) 1 byte
d)
8 bytes
38 Programming and Data Structures
4) C keywords are reserved words by
a) a compiler b)
c) header file d)
5) The maximum length of the C variable can be
a) 10 characters b)
c) 20 characters d)
6) The declaration of C variable can be done
a) anywhere in the program b)
c) in executable part d)
7) In C one statement can declare
a) only one variable b)
c) ten variables d)
8) The word 'inf is a
a) keyword b)
c) header file d)
9) The variables are initialized using
a) greater than (>) b)
c) twice equal to (==) d)
10) An unsigned integer variable contains values
a) greater than or equal to zero b)
c) only zeros d)
11) The keyword 'const' keeps the value of a variable
a) constant b)
c) variant d)
12) Identifiers are
a) user-defined names b)
c) C statements d)
13) In C every variable has
a) a type b)
c) a value d)
e) all of the above
14) The range of character data type is
a) -128 to 127 b)
c) 0 to 32767 d)
15) The keyword 'volatile' keeps the value of variable
a) constant b)
c) variant d)
16) Which is the incorrect variable name?
a) else b)
an interpreter
(b)&(c)
8 characters
none of the above
in declaration part
at the end of the program
two variables
any number of variables
password
none of the above
equal to (=)
an increment operator (++)
less than zero
(a) & (b) both
mutable
none of the above
reserved keywords
none of the above
a name
a size
0 to 255
none of the above
mutable
none of the above
name
The C Declarations 39
c) age
d)
cba_r
How many keywords are there in ANSI C?
a) 32
b)
33
c) 42
d)
15
How many variables can be initialized at a time?
a) one
b)
two
c) five
d)
any number of variables
Which of the following statements is wrong?
a) 5+5=a;
b)
SS=12.25;
c) st='m' * 'b ';
d)
is ='A'+10;
The ANSI Standard recognizes the maximum length of a variable up to
a) 31characters
b)
8 characters
c) 25 characters
d)
unlimited characters
The variable name can be started with
a) underscore symbol (_)
b)
asterisk symbol (*)
c) ampersand symbol (&)
d)
none of the above
22) What is the output of the following program?
# include <stdio.h>
# include <conio.h>
void main ()
{
unsigned long v=-l;
clrscr ();
printf ("\n %lu", v);
}
a) 4294967295
c) -1
23) What would be the value of variable c and u?
# include <stdio.h>
# include <conio.h>
void main ()
b)
d)
0
none of the above
{
}
a)
c)
char c=-127;
unsigned char u=-127;
clrscr ();
printf ("\n c=%d u= %d",c,u);
c=127 u=127
c=127 u=128
b)
d)
c= -127 u=127
none of the above

Get Programming and Data Structures now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.