Click to Get updated NTA UGC NET CS Test Series           Study Material for UGC NET Computer Science- 2019

C Programming MCQ - I/O Operations

51:   For x and y are variables as declared below
double x=0.005,y=-0.01;
What is the value of ceil(x+y)
A. 1
B. 0
C. 0.005
D. Error
 
 

Option: A

Explanation :

Click on Discuss to view users comments.

Write your comments here:



52:   If the following program fragment(assume negative numbers are stored in 2's complement form)
unsigned i=1;
int j=-4;
printf("%d",8*size of(int));
output is (log in answers are to the base two)
A. An unpredictable value
B. 8*log(x+3)
C. log(x+3)
D. None of these
 
 

Option: C

Explanation :
Let size of (int)=1. So, -4 will be stored as 11111100. Since we are adding unsigned and signed integers the signed gets converted to unsigned. So, i + j will become 11111101. We are trying to print this as an unsigned integer.
So, what is printed will be 2⁸-1-2. So, log (x+3)=8(i.e,*size of (int)).

Click on Discuss to view users comments.

barbee doll said: (3:10pm on Tuesday 8th August 2017)
Please explain it that how -4 will be stored in 11111100 form while 4 binary form is that 00000101

Write your comments here:


unsigned i=1;
int j=-4;
printf("%d",8*size of(int));
output is (log in answers are to the base two)'>
53:   Output of the following program fragment (in C) is
for (i = 1; i < 5; i ++);
if (i = = 3) continue;
else printf ("%d",i);
A. 1 2 3 4 5
B. 1 2 4
C. 2 4 5
D. none of these
 
 

Option: B

Explanation :

Click on Discuss to view users comments.

Write your comments here:



54:   The following 'C' program
{
unsigned int num;
int c=0
scanf("%u",&num);
for(;num;num>>=1)
{
if(num &1)
c++;
}
printf("%d",c);
}
A. Counts the number of bits which are on in the number num
B. Sets all bits in the number num to 1
C. Sets bits in the number num to 0
D. Error
 
 

Option: A

Explanation :

Click on Discuss to view users comments.

Write your comments here:


{
unsigned int num;
int c=0
scanf("%u",&num);
for(;num;num>>=1)
{
if(num &1)
c++;
}
printf("%d",c);
}'>
55:   Find the output of following code segment
for(putchar('c');putchar('a');putchar('r'))
putchar('t');
A. A syntax error
B. Cartrta
C. Catrat
D. Catratratratrat...
 
 

Option: D

Explanation :

Click on Discuss to view users comments.

Write your comments here:


putchar('t');'>



X