0% found this document useful (0 votes)
18 views5 pages

Data Types and Operator _ DPP 01

The document contains a set of questions and answers related to C programming, covering topics such as identifiers, keywords, operators, precedence, and code output. It includes multiple-choice questions (MCQs) along with hints and solutions for each question. The document serves as a practice paper for GATE Computer Science & Information Technology examination.

Uploaded by

jatinshivjangid
Copyright
© © All Rights Reserved
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)
18 views5 pages

Data Types and Operator _ DPP 01

The document contains a set of questions and answers related to C programming, covering topics such as identifiers, keywords, operators, precedence, and code output. It includes multiple-choice questions (MCQs) along with hints and solutions for each question. The document serves as a practice paper for GATE Computer Science & Information Technology examination.

Uploaded by

jatinshivjangid
Copyright
© © All Rights Reserved
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/ 5

1/27/25, 10:12 PM GATE_Computer Science & Information Technology_DPP 1

GATE

Computer Science & Information Technology


C - Programming
DPP: 1
Data Types & Operators

Q1 Which of the following is not a valid identifier? (C) Operators (D) Expressions
(A) main (B) sizeof
Q7 Any number with fractional part is said to
(C) _PW (D) _PW_
be ________
Q2 Which of the following is not a keyword? (A) Integer Constant
(A) goto (B) volatile (B) Real Constant
(C) main (D) unsigned (C) Character Constant
(D) String Constant
Q3 What is the output of below C Code?
void main() Q8 What will be the output of below 'C' code?
{ void main()
int a=7,b=5,c,d; {
c= a++ + ++b; int i=+17, j=-7;
d= --b + a--; printf("%d,%d", i/j, i%j);
printf("%d %d", d, c); }
} (A) –2, +3
(A) 13, 12 (B) 12, 12 (B) +2, –3
(C) 12, 13 (D) 13, 13 (C) +2, +3
(D) -2, –3
Q4 The output of below C code is ______
void main() Q9 Identify the correct Precedence of below
{ operators:
int i=9, j=12, k, x; (I) ++ (Postfix)
k=i=j; (II) && (Logical AND)
x=i==j; (III) ^(Bitwise XOR)
printf("%d %d", k, x); (IV) >> (Right Shift)
} (A) I, II, III, IV
(A) 9, 12 (B) 12, 1 (B) I, III, II, IV
(C) 12, 0 (D) 9, 0 (C) I, IV, II, III
(D) I, IV, III, II
Q5 The smallest individual element of any 'C'
program is called as _________ Q10 Match the following:
(A) Variables LIST - I LIST - II
(B) Constants A. || 1. Relational
(C) Tokens
B. != 2. Unary
(D) Keywords
C. +(sign) 3. Bitwise
Q6 Which of the below is not a 'C' Token? (A) A-2, B-3, C-1
(A) Identifiers (B) Keywords (B) A-3, B-2, C-1

Android App | iOS App | PW Website

https://qbg-admin.penpencil.co/finalize-question-paper/print-preview 1/5
1/27/25, 10:12 PM GATE_Computer Science & Information Technology_DPP 1

GATE

(C) A-3, B-1, C-2 int i=5, j=-3, k=0;


(D) A-2, B-1, C-3 int x;
x= i ? j ? k ? k : i : j : k;
Q11 Which of the below operators associativity is
printf("%d", x);
Right To Left?
}
(A) Shift Operators
(A) 0 (B) –3
(B) Logical Operators
(C) 5 (D) Error
(C) Prefix, Unary Operators
(D) Arithmetic Operators Q15 Match The Following
List-I List-II
Q12 Which combination of the integer variables x, y
a. & 1. Indirection
and z makes the variable a get the value 4 in the
following expression? b. * 2. Arithmetic Division

a = ( x > y ) ? (( x > z ) ? x : z) : (( y > z ) ? y : z ) c.-> 3. Bitwise


(A) x = 3, y = 4, z = 2 d. >> 4. Member Access
(B) x = 6, y = 5, z = 3 (A) a-2, b-3, c-1, d-4
(C) x = 6, y = 3, z = 5 (B) a-3, b-1, c-2, d-4
(D) x = 5, y = 4, z = 5 (C) a-3, b-1, c-4, d-2
(D) a-3, b-4, c-1, d-2
Q13 The output of below C code is _______
void main() Q16 What is the output of below code?
{ int main()
int x; {a
x= 7 + 4 * 5 / 2 - 2; int a;
printf("%d", x); a= 18 + 43/2 * 3 >> 4 - 2;
(A) 15 (B) 13 printf("%d", a);
(C) 25 (D) 11 return 0;
}
Q14 The output of below code will be _______
(A) 3 (B) 4
void main()
(C) 5 (D) 20
{

Android App | iOS App | PW Website

https://qbg-admin.penpencil.co/finalize-question-paper/print-preview 2/5
1/27/25, 10:12 PM GATE_Computer Science & Information Technology_DPP 1

GATE

Answer Key
Q1 (B) Q9 (D)

Q2 (C) Q10 (C)

Q3 (D) Q11 (C)

Q4 (B) Q12 (A)

Q5 (C) Q13 (A)

Q6 (D) Q14 (C)

Q7 (B) Q15 (C)

Q8 (A) Q16 (D)

Android App | iOS App | PW Website

https://qbg-admin.penpencil.co/finalize-question-paper/print-preview 3/5
1/27/25, 10:12 PM GATE_Computer Science & Information Technology_DPP 1

GATE

Hints & Solutions


Q1 Text Solution: and x. Therefore, the output is:12 1. therefore
In most programming languages, including C option b is correct
and C++, identifiers are names given to variables, Q5 Text Solution:
functions, classes, etc. These names must The smallest individual element of any 'C'
follow certain rules: program is called a token.
1. They cannot be a keyword or reserved word of So, the correct answer is:
the programming language. c. Tokens
2. They must start with a letter (a to z or A to Z)
Q6 Text Solution:
or an underscore (_).
Among the options provided, "Expressions" is not
3. The subsequent characters can be letters,
a token in the C programming language.
digits (09), or underscores.
Expressions are combinations of operators,
4. Identifiers are case-sensitive. Based on these
operands, and other expressions that evaluate to
rules, the correct answer is: b. sizeof
a single value. Tokens in C include identifiers,
Q2 Text Solution:
keywords, and operators, but expressions are not
In the C programming language, "volatile" is a
considered tokens themselves.
keyword used to declare that a variable can be
So, the correct answer is: d) Expressions
modified unexpectedly by hardware or other
Q7 Text Solution:
parts of the program. On the other hand, "main",
Any number with a fractional part is said to be a
"goto", and "unsigned" are all keywords in C.
real constant.
Therefore, the correct answer is:
So, the correct answer is:
c. main
b. Real Constant
Q3 Text Solution:
Q8 Text Solution:
1. c = a++ + ++b;- a++ means post-increment, so a
1. i is assigned the value of positive 17 (+17).
is used as 7 and then incremented to 8.- ++b
2. j is assigned the value of negative 7 (-7).
means pre-increment, so b is incremented to 6
3. The expression i/j is integer division, which in
and then used as 6.- c = 7 + 6 = 1
C truncates towards zero. So 17 / -7 results in -2.
2. d = --b + a--;---b means pre-decrement, so b is
4. The expression i%j calculates the remainder of
decremented to 5 and then used as 5.- a-- means
the division 17 % -7, which is 3.
post-decrement, so a is used as 8 and then
So, the output of the code will be:-2,3 which is
decremented to 7.- d = 5 + 8 = 13 both d and c
option a.
indeed result in 13. Therefore, the correct answer
is: d. 13, 13
Q9 Text Solution:
Q4 Text Solution:
(I) ++ (Postfix)
i = 9 and j = 12 and assigns k and x later. In the
(II) && (Logical AND)
statement k = i = j;, the value of j (12) is assigned
(III) ^ (Bitwise XOR)
to i, and then i (now 12) is assigned to k. Thus, k =
(IV) >> (Right Shift)
12. Next, in x = i == j;, the comparison i == j
The correct order is: d. I, IV, III, II
evaluates to true (since both are 12), so x = 1.
Finally, the printf statement prints the values of k Q10 Text Solution:

Android App | iOS App | PW Website

https://qbg-admin.penpencil.co/finalize-question-paper/print-preview 4/5
1/27/25, 10:12 PM GATE_Computer Science & Information Technology_DPP 1

GATE

The correct matching is: Next, addition and subtraction are performed
A. || - 1. Relational from left to right:
B. != - 2. Unary 7 + 10 = 17
C. +(sign) - 3. Bitwise the correct match is: c. A-3, 17 - 2 = 15
B-1, C-2 So, the value of x is 15.

Q11 Text Solution: Therefore, the correct answer is: a. 15

The operator associativity that is Right to Left is: Q14 Text Solution:
c. Prefix, Unary Operators The code uses nested ternary operators. Since i is

Q12 Text Solution: non zero (true), it evaluates the expression after

(A) x = 3, y = 4, z = 2 a = (3 > 4) ? ((3 > 2) ? 3 : 2) : the first ?, which is j ? k ? k : i : j. The nested

((4 > 2) ? 4 : 2) ternary operators lead to the value of i, which is

Since x is not greater than y, the ternary 5. Therefore, the output is 5.

expression evaluates to ((4 > 2) ? 4 : 2), which is 4. Q15 Text Solution:


a. & 3. Bitwise
(B) x = 6, y = 5, z = 3 a = (6 > 5) ? ((6 > 3) ? 6 : 3) : The & operator is indeed a bitwise AND
((5 > 3) ? 5 : 3) operator.
In this case, the first condition is true, so it b. * 1. Indirection
evaluates to ((6 > 3) ? 6 : 3), which is 6. The * operator is commonly used for indirection
or dereferencing, especially with pointers.
(C) x = 6, y = 3, z = 5 c. -> 4. Member Access
a = (6 > 3) ? ((6 > 5) ? 6 : 5) : ((3 > 5) ? 3 : 5) The -> operator is used for member access
Again, the first condition is true, so it evaluates to instructures and unions.
((6 > 5) ? 6 : 5), which is 6. d. >> 2. Arithmetic Division
The >> operator is used for right shift in
(D) x = 5, y = 4, z = 5 bitwise operations.
a = (5 > 4) ? ((5 > 5) ? 5 : 5) : ((4 > 5) ? 4 : 5) Given this, the correct match is indeed:
The first condition is true, so it evaluates to ((5 > C. a3, b1, c4, d2
5) ? 5 : 5), which is 5. Q16 Text Solution:
Therefore, the correct combination is (A) x = 3, y = The output of the above program will be 20. : 43
4, z = 2, which makes a equal to 4. / 2 evaluates to 21 (integer division).
Q13 Text Solution: 21 * 3 results in 63.
x=7+4*5/2-2 63 >> 4 is a right shift operation by 4 bits, which
First, multiplication and division are performed effectively divides the value by 2^4 = 16. So, 63
from left to right: >> 4 becomes 3.
4 * 5 = 20 Finally, 18 + 3 - 2 equals 20.
20 / 2 = 10 Therefore, the value of a is 20. Hence option d is
Now, the expression becomes: correct.
x = 7 + 10 - 2

Android App | iOS App | PW Website

https://qbg-admin.penpencil.co/finalize-question-paper/print-preview 5/5

You might also like