Let Us C Solution
Let Us C Solution
Let Us C Solution
a=2 b=3
(f) main( ) { int p, q ; printf ( "Enter values of p and q" ) ; scanf ( " %d %d
", &p, &q ) ; printf ( "p = %d q =%d", p, q ) ; } Enter values of p and q 5 10 p
=5 q=10 [G] Pick up the correct alternative for each of the following questions:
(a) C language has been developed by (1) Ken Thompson (2) Dennis Ritchie (3) Pe
ter Norton (4) Martin Richards (b) C can be used on (1) Only MS-DOS operating sy
stem (2) Only Linux operating system (3) Only Windows operating system (4) All t
he above (c) C programs are converted into machine language with the help of (1)
An Editor (2) A compiler (3) An operating system (4) None of the above (d) The
real constant in C can be expressed in which of the following forms (1) Fraction
al form only (2) Exponential form only (3) ASCII form only (4) Both fractional a
nd exponential forms (e) A character variable can at a time store (1) 1 characte
r (2) 8 characters (3) 254 characters (4) None of the above (f) The statement ch
ar ch = Z would store in ch (1) The character Z (2) ASCII value of Z (3) Z along w
ith the single inverted commas (4) Both (1) and (2) (g) Which of the following i
s NOT a character constant (1) Thank You (2) Enter values of P, N, R (3) 23.56E-03 (4
All the above
(h) The maximum value that an integer constant can have is (1) -32767 (2) 32767
(3) 1.7014e+38 (4) 1.7014e+38 (i) A C variable cannot start with (1) An alphabet
(2) A number (3) A special symbol other than underscore (4) Both (2) & (3) above
(j) Which of the following statement is wrong (1) mes = 123.56 ; (2) con = 'T'
* 'A' ; (3) this = 'T' * 20 ; (4) 3 + a = b ; (k) Which of the following shows t
he correct hierarchy of arithmetic operators in C (1) **, * or /, + or (2) **, *
, /, +, (3) **, /, *, +, (4) / or *, - or + (l) In b = 6.6 / a + 2 * n; which op
eration will be performed first? (1) 6.6 / a (2) a + 2 (3) 2 * n (4) Depends upo
n compiler (m) Which of the following is allowed in a C Arithmetic instruction (
1) [ ] (2) { } (3) ( ) (4) None of the above (n) Which of the following statemen
ts is false (1) Each new C instruction has to be written on a separate line (2)
Usually all C statements are entered in small case letters (3) Blank spaces may
be inserted between two words in a C statement (4) Blank spaces cannot be insert
ed within a variable name (o) If a is an integer variable, a = 5 / 2 ; will retu
rn a value (1) 2.5 (2) 3 (3) 2 (4) 0 (p) The expression, a = 7 / 22 * ( 3.14 + 2
) * 3 / 5 ; evaluates to (1) 8.28 (2) 6.28 (3) 3.14 (4) 0 (q) The expression, a
= 30 * 1000 + 2768 ; evaluates to (1) 32768 (2) -32768 (3) 113040
(4) 0 (r) The expression x = 4 + 2 % - 8 evaluates to (1) -6 (2) 6 (3) 4 (4) Non
e of the above (s) Hierarchy decides which operator (1) is most important (2) is
used first (3) is fastest (4) operates on largest numbers (t) An integer consta
nt in C must have: (1) At least one digit (2) At least one decimal point (3) A c
omma along with digits (4) Digits separated by commas (u) A character variable c
an never store more than (1) 32 characters (2) 8 characters (3) 254 characters (
4) 1 character (v) In C a variable cannot contain (1) Blank spaces (2) Hyphen (3
) Decimal point (4) All the above (w) Which of the following is FALSE in C (1) K
eywords can be used as variable names (2) Variable names can contain a digit (3)
Variable names do not contain a blank space (4) Capital letters can be used in
variable names (x) In C, Arithmetic instruction cannot contain (1) variables (2)
constants (3) variable names on right side of = (4) constants on left side of =
(y) Which of the following shows the correct hierarchy of arithmetic operations
in C (1) / + * (2) * - / + (3) + - / * (4) * / + (z) What will be the value of
d if d is a float after the operation d = 2 / 7.0? (1) 0 (2) 0.2857 (3) Cannot b
e determined (4) None of the above
Exercises Chapter 2
(f) main( ) { int a = 40 ; if ( a > 40 && a < 45 ) printf ( "a is greater than 4
0 and less than 45" ) ; else printf ( "%d", a ) ; }
40
(g) main( ) { int p = 8, q = 20 ; if ( p == 5 && q > 5 ) printf ( "\nWhy not C"
) ; else printf ( "\nDefinitely C !" ) ; }
Definitely C!
(h) main( ) { int i = -1, j = 1, k ,l ; k = i && j ; l = i || j ; printf ( "%d %
d", i, j ) ; }
1 1
(i) main( ) { int x = 20 , y = 40 , z = 45 ; if ( x > y && x > z ) printf( "x is
big" ) ; else if ( y > x && y > z ) printf( "y is big" ) ; else if ( z > x && z
> y ) printf( "z is big" ) ; }
z is big
(j) main( ) { int i = -1, j = 1, k ,l ; k = !i && j ; l = !i || j ; printf ( "%d
%d", i, j ) ; }
-1 1
(k) main( ) {
}
Welcome
[H] Point out the errors, if any, in the following programs: (a) main( ) { int t
ag = 0, code = 1 ; if ( tag == 0 ) ( code > 1 ? printf ( "\nHello" ) ? printf (
"\nHi" ) ) ; else printf ( "\nHello Hi !!" ) ; }
Hi
(b) main( ) { int ji = 65 ; printf ( "\nji >= 65 ? %d : %c", ji ) ; } ji >= 65 ?
%d : %c (c) main( ) { int i = 10, j ; i >= 5 ? ( j = 10 ) : ( j = 15 ) ; printf
( "\n%d %d", i, j ) ; }
10 10
(d) main( ) { int a = 5 , b = 6 ; ( a == b ? printf( "%d",a) ) ; }
Syntax error, missing : before )
(e) main( ) { int n = 9 ; ( n == 9 ? printf( "You are correct" ) ; : printf( "Yo
u are wrong" ) ;) ; }
Syntax error, ; before:
(f) main( ) { int kk = 65 ,ll ; ll = ( kk == 65 : printf ( "\n kk is equal to 65
" ) : printf ( "\n kk is not equal to 65" ) ) ; printf( "%d", ll ) ; } Syntax er
ror