0% found this document useful (0 votes)
12 views

Data Types

Uploaded by

tushar
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)
12 views

Data Types

Uploaded by

tushar
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

1

CSE/IT
Programming in C
Operators DPP-02

[MCQ] a=25>15>0!=12<45>42!
1. include <stdio.h> = 65;
int main(void){ printf("%d",a);
int a;
}
a = 2 * 6/5 + 3.0/2 + 1;
printf("%d", a); The output is ______.
return 0;
} [MCQ]
The value of a is ___ 5. Consider the following program:
(a) 4.9 (b) 4.0 #include<stdio.h>
(c) 4.5 (d) 4 void main()
{
[MCQ] int a=0, b=1;
2. #include <stdio.h> a=(a=5)&&(b=0);
int main(void){ printf("%d", a);
int a; printf("%d", b);
a = 16.0 /4 * 5 % 3; }
printf("%d", a); The output is:
return 0; (a) 50 (b) 00
} (c) 10 (d) Compiler error
The value of a printed is ___
(a) Compiler error (b) 8.0 [MCQ]
(c) 2 (d) 8 6. Consider the following statements:
P: The precedence of the modulus operator is higher
[NAT] than multiplication or division operator.
3. Consider the following program. Q: The result of the modulus operator contains the sign
#include<stdio.h> of the second operand.
void main()
Which of the following statements is/are
{
INCORRECT?
int a;
(a) Only P
a=32>24>13>10>8>-1>0;
printf("%d",a); (b) Only Q
} (c) Both P and Q
The output is . (d) Neither P nor Q

[NAT] [MCQ]
4. #include<stdio.h> 7. Consider the following program:
void main() #include<stdio.h>
{ void main()
int a; {
int a=2022;
2

printf("%d%d%d", a!=2024, a=2023, a==2021); void main()


} {
The output is- int x=-2023;
(a) 020220 (b) 020231 printf("%d", ~(x=x+5)) ;
(c) 002021 (d) 120230 }
The output is __________.
[NAT]
8. Consider the following program:
#include<stdio.h>
3

Answer Key
1. (d) 5. (b)
2. (a) 6. (c)
3. (1) 7. (d)
4. (1) 8. (2017)
4

Hints and Solutions

1. (d) Output: 1
a = 12/5 + 3.0/2 + 1
= 2 + 1.5 + 1 5. (b)
= 4.5 int a=0, b=1;
a is an integer, so a = 4 a=(a=5)&&(b=0);
// Assignment operator assigns and returns the assigned
value. So, a=5&&0=0, b=0
2. (a)
printf("%d", a);//0 is printed
a = 16.0/4 * 5 % 1
= 4.0 * 5 % 3 printf("%d", b);//0 is printed.
= 20.0 % 3
= ERROR 6. (c)
Modulus operator works only with integers. P: INCORRECT. The precedence of the modulus
operator is same as multiplication or division operator.
3. (1) Q: INCORRECT. The result of the modulus operator
a = 32 > 24 > 13 > 10 > 8 > –1 > 0 contains the sign of the first operand.
1 > 13  0 > 10
7. (d)
0>8
a=2022. So, a!=2024 evaluates to 1.
0>–1
a=2023. Assignment operator assigns the value
1>0
and returns the assigned value.
1
a==2021 is equivalent to 2023==2021. So, it
a=1
evaluates to 0.
Output: 120230
4. (1)
8. (2017)
a = 25 > 15 > 0! = 12 < 45 > 42! = 65
x=x+5 → x=-2023+5=-2018
1>0
~(x) → ~(-2018) = -(-2018+1) = 2017.
1! = 12
Output: 2017.
1 < 45
1 > 42  0! = 65
1
a=1;

For more questions, kindly visit the library section: Link for app: https://physicswallah.live/tabs/tabs/library-tab
For more questions, kindly visit the library section: Link for web: https://links.physicswallah.live/vyJw
Any issue with DPP, please report by clicking here- https://forms.gle/t2SzQVvQcs638c4r5

PW Mobile APP: https://play.google.com/store/apps/details?id=xyz.penpencil.physicswala


For PW Website: https://www.physicswallah.live/contact-us

You might also like