0% found this document useful (0 votes)
3 views4 pages

C Programming Operators DPP 01

The document contains a series of programming exercises and questions related to C programming operators, including code snippets and multiple-choice questions. It provides answers and explanations for the output of various code examples, focusing on concepts like data types, conditional statements, and operator behavior. Additionally, it includes hints and solutions for understanding the results of the programs presented.

Uploaded by

Anbu Alwin
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)
3 views4 pages

C Programming Operators DPP 01

The document contains a series of programming exercises and questions related to C programming operators, including code snippets and multiple-choice questions. It provides answers and explanations for the output of various code examples, focusing on concepts like data types, conditional statements, and operator behavior. Additionally, it includes hints and solutions for understanding the results of the programs presented.

Uploaded by

Anbu Alwin
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/ 4

C Programming - Operators

DPP- 1

1. Consider the following program. [NAT] 5. Consider the following program [MCQ]
#include<stdio.h> #include<stdio.h>
void main() void main()
{
{
int a=0, b=1;
int a; a=32>24>13>10>8>-1>0;
a=(a=5)&&(b=0);
printf("%d",a); printf("%d", a);
} printf("%d", b);
The output is. }
The output is:
2. Consider the following program. [NAT] A. 50 B. 00
#include <stdio.h> C. 10 D. Compiler error
int main()
{ 6. Consider the following declarations:
char ch=127; P: signed short x;
ch=ch+6; Q: unsigned long long int x;
printf("%d", ch); Which of the given declarations is/are
return 0; CORRECT? [MCQ]
} A. Only P
B. Only Q
3. Consider the following program. [NAT] C. Both P and Q
#include <stdio.h> D. Neither P nor Q
int main()
{ 7. Consider the following function: [MCQ]
int x = -32769; #include <stdio.h>
printf("%d", x); int main()
return 0; {
} char ch = –134; printf("%c", ch);
Ans : 65536 - 32769=32767 return 0;
}
4. Consider the following function: [MCQ] The output is-
#include <stdio.h> A. A
int main() { B. Garbage
char ch = 141; C. Compiler Error
printf("%d", ch); D. z
return 0;
} 8. Which of the following is/are valid declarations
A. -115 B. 115 of a signed short integer? [MSQ]
C. 141 D. -141 A. short int a;
B. short a;
C. signed short a;
D. signed short int a;
C Programming - Operators
DPP- 1

9. Consider the following function: [MCQ] D) Condition is false, Values


#include <stdio.h> after evaluation - y: 0, z: 5
int main(void){
int a = 3 > 2 ? 0 ? 0 : 1 : 5;
if(a = = a – 1)
printf(“GFG GATE 2025”);
else
printf(“GATE GFG”);
return 0;
}
The output of the following program is.
A. GFG GATE 2025
B. GATE GFG
C. Compiler error
D. Garbage value

10. Consider the following function: [MCQ]


#include <stdio.h>
int main()
{
int x = 3, y = 0, z = 5;

if (x || y++ && z++)


{
printf("Condition is true\n");
}
else
{
printf("Condition is false\n");
}
printf("Values after evaluation - y: %d, z:
%d\n", y, z);
return 0;
}

A) Condition is true, Values


after evaluation - y: 1, z: 6

B) Condition is true, Values


after evaluation - y: 0, z: 5

C) Condition is false, Values


after evaluation - y: 1, z: 6
C Programming - Operators
DPP- 1

Answer Key

1.Answer : 1
2.Answer : -123
3.Answer : 32767
4.Answer : A
5.Answer : B
6.Answer : C
7.Answer : z
8.Answer (A, B, C, D)
9. Answer B
10. Answer B
C Programming - Operators
DPP- 1

Hints & Solution Unsigned value for –134= 256 – 134 = 122.
Hence, ‘z’ is printed.
1. Answer : 1
a = 32 > 24 > 13 > 10 > 8 > –1 > 0 8. Answer (A, B, C, D)
1 > 13 Þ 0 > 10 All are valid declarations.
0>8
0>–1
1>0
1
a=1 9. Answer : B

2. Answer : -123 a=1


Signed char range in c is -128 to 127.
Assignment operator assigns the value and
127 + 6 = 133,
returns it
133 in an 8-bit signed representation:
133 - 256 = -123 if(a = a – 1) =>Condition: false

3. Answer : 32767 Output: GATE GFG


65536-32769=32767
10. Answer : B
4. Answer : A
x is true(non-zero value) then ||(logical OR)
141 is 14 steps ahead of 127. After 127, 14
operator is short circuited.
steps are counted from –128(including -128) as
(y++ && z++) is not evaluated.
–128, –127, –126, –125, –124, –123, –122, –121,
–120, –119, –118, –117, –116, –115. Thus, y remains 0, and z
remains 5.
Printed value = –115.

5. Answer : B
int a=0, b=1; a=(a=5)&&(b=0);
// Assignment operator assigns and returns
the assigned value. So, a=5&&0=0, b=0
printf("%d", a);
//0 is printed
printf("%d", b);
//0 is printed.

6. Answer : C
Both P and Q are valid declarations.

7. Answer : z

You might also like