|
C Fundamentals
|
|
Data Types, Constants & Variables, Playing with scanf function, Operators & Expressions
|
|
[Q001]
|
|
(a)
VALID (b) Invalid, since an identifier must begin
with a letter or an underscore (c) VALID (d)
Invalid, since return is a reserved word (e) Invalid,
since an identifier must begin with a letter or an
underscore (f) VALID (g) Invalid, since an
identifier must begin with a letter or an
underscore (h) Invalid, since blank spaces are not
allowed (i) VALID (j) VALID
|
|
|
|
[Q002]
|
|
(a)
VALID (b) VALID (c) VALID (d) VALID (e)
Invalid, since escape sequences must be written with a
backward slash (i.e. \) (f) Invalid, since a
character constant cannot consist of multiple
characters (g) VALID (null-character escape
sequence) (h) VALID (i) VALID (Octal escape
sequence) (j) VALID (k) VALID
|
|
|
|
[Q003]
|
|
(a)
'Hi Friends' (b) "abc,def,ghi" (c)
"Qualification (d) "4325.76e-8" (e)
"Don\'t sleep" (f) "He said, "You\'re
great" (g) "" (h) " " (i)
"Rs.100/-"
|
|
|
|
[Q004]
|
|
(a) Invalid,
since illegal character(,) (b) VALID (c)
VALID (d) VALID (e) VALID (f) VALID (g)
Invalid, since illegal character(blank space) (h)
Invalid, since illegal character(s) (i) VALID (j)
Invalid, since illegal characters (9, C, F), if intended
as an octal constant. (k) VALID (l)
VALID
|
|
|
|
[Q005]
|
|
(k) All
of the above
|
|
|
|
[Q006]
|
|
(d)123.000000
123. is a
valid double value and it is equivalent to
123.000000
|
|
|
|
[Q007]
|
(b)Compile-Time
Error
The data type
'integer' doesn't exist. It should be 'int'.
|
|
|
|
[Q008]
|
(c)15
Length of the
string 'C For Swimmers' is 14 + Null('\0') = 15
Characters
|
|
|
|
[Q009]
|
|
(b)Compile-Time
Error
Pre- or Post-
increment/decrement operators cannot be used on the
constants as shown in the above scenario. But it can be
used with variables to increment the contents or address
by 1.
|
|
|
|
[Q010]
|
(c)-15
After
computing the size in bytes, the binary operator -
(minus) is used to change the sign of the
resultant.
|
|
|
|
[Q011]
|
(c)1
Negation (!) of non-zero value always
returns 0 (zero). Thus 0 + 1 = 1
|
|
|
|
[Q012]
|
|
(c)0
Be careful
while evaluating such type of expressions. Consider the
precedence during computation which plays a major role.
Here y/z yields 3 which is equal to 3. Thus the true
expression in the ternary operator y/z yields 3. Thus
z/=3 or z=2/3 yields 0 (zero) because of integer
division. Finally it prints 0 (zero) onto the
screen.
|
|
|
|
[Q013]
|
|
(c)5 0
25
Negation (!)
of non-zero value always returns 0 (zero). Thus the
arguments to the printf will be 5 0 25-0. Thus it prints
5 0 25
|
|
|
|
[Q014]
|
|
(d)300 -200 300 10
4
Be careful
while evaluating such type of expression. Precedence
plays a major role during computation. Here the
short-hand assignment operators precedence is from
R->L. Thus it prints 300 -200 300 10
4
|
|
|
|
[Q015]
|
|
(b)Failure
Apply the
relational & logical operators properly to arrive at
the solution. Thus it prints the message
'Failure'.
|
|
|
|
[Q016]
|
|
(a)1
Here evaluate
the ternary operators carefully. Here !a yields 0 so it
enters into the false block and return the value of a.
Thus it prints 1.
|
|
|
|
[Q017]
|
|
Execute &
understand the output format.
|
|
|
|
[Q018]
|
|
Execute &
understand the output format.
|
|
|
|
[Q019]
|
|
Execute &
understand the output format.
|
|
|
|
[Q020]
|
|
Execute &
understand the output format.
|
|
|
|
[Q021]
|
|
Execute & understand the output
format.
|
|
|
|
[Q022]
|
(d)100 300 3
The *
(asterisk) in the scanf statement indicates an
assignment suppression operator that skips the related
value and picks the next value in the input
series.
|
|
|
|
[Q023]
|
(b)Dear
Friends
Here the ,
(comma) is used as the termination character. The scanf
statement in the above code accepts the string that
contains anything other than the ,
(comma).
|
|
|
|
[Q024]
|
(b)a=A b=
c=B
While accepting we're expecting NO whitespaces between the three different
inputs i.e. characters but we've encountered characters in the actual
input.
|
|
|
|
[Q025]
|
(c)5
2.25
Here we're
expecting an integer (int) value followed by a
whitespace, which is followed by a character 'a', which
in turn followed by a whitespace and a float value. But
the actual input doesn't meet our requirements hence the
only the matched arguments are taken into
consideration.
|
|
|
|
[Q026]
|
(b)a=A b=B
c=C
We're
expecting character inputs separated by whitespaces but
the actual input contains string of
characters.
|
|
|
|
[Q027]
|
(b)C Means
Sea
Here access
format specifier is used in the scanf statement similar
to the access format specifier usage in the printf
statements.
|
|
|
|
[Q028]
|
(a)Sum=480
Here access
format specifier is used in the scanf statement similar
to the access format specifier usage in the printf
statements.
|
|
|
|
[Q029]
|
(c)Accepts the string that
contains anything other than the DIGITS and NEWLINE
characters.
^ indicates
negation operation.
|
|
|
|
[Q030]
|
(c)Accepts the string that
contains anything other than the * or asterisk
character.
^ indicates
negation operation.
|
|
Back
|
|
Next
|
|