C Programming Operators DPP 01
C Programming Operators DPP 01
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
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
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