Programming

Question 1
Consider the following C++ program Assuming the required header files are already included, the above program:
A
results in a compilation error
B
print 123
C
print 111
D
print 322
       Programming       Operator       ISRO-2018
Question 1 Explanation: 
Solution: A but official key given solution D
→ It gives compilation error because declaration of “intc” is wrong.
→ q+=b(a(q)) and r+=a(c(r)) will result compilation error.
Question 2
An array A consists of n integers in locations A[0], A[1] ….A[n-1]. It is required to shift the elements of the array cyclically to the left by k places, where 1 <= k <= (n-1). An incomplete algorithm for doing this in linear time, without using another array is given below. Complete the algorithm by filling in the blanks. Assume alt the variables are suitably declared.
A
i > min; j!= (n+i)mod n; A[j + k]; temp; i + 1 ;
B
i < min; j!= (n+i)mod n; A[j + k]; temp; i + 1;
C
i > min; j!= (n+i+k)mod n; A[(j + k)]; temp; i + 1;
D
i < min; j!= (n+i-k)mod n; A[(j + k)mod n]; temp; i + 1;
       Programming       Arrays       ISRO-2018
Question 2 Explanation: 
This question need presence of mind.
Step-1: Observe all options, 4 options they are given 4th and 5th blank is temp and i+1.
So, they given clue that, 4th and 5th options must be temp and i+1.
Step-2: Based on the 4th and 5th options, we can guess that 1st blank is i → Suppose if we are considering i>min then the control goes out of the while loop in the initial case when i=0 and min=n. So, 1st blank should be i Step-3: According to 1st blank, we can eliminate A and C options.
Step-4: Assume 2nd blank is correct, we are considering j!= (n+i) mod n this condition in while loop.
→ The meaning of the condition is “j becomes equal to (n+i)mod n then control goes out of the while loop.”
Step-5: The condition (n+i)mod n=i and j is always equal to i because we are assigning the value of i to j in the code segment line 3.
Step-6: based on these constraint we can say that 4th option is correct.
Reason: The control never enters the 2nd while loop. Sometimes it will enter the 2nd while loop, when we shift the numbers. It means total K places left.
Question 3
Consider the following C function
A
Call swap (a, b)
B
Call swap (&a, &b)
C
swap(a, b) cannot be used as it does not return any value
D
swap(a, b) cannot be used as the parameters passed by value
       Programming       Functions       ISRO-2017 May
Question 3 Explanation: 
Question 4
What does the following C-statement declare? int (*f) (int*);
A
A function that takes an integer pointer as an argument and returns an integer
B
A function that takes an integer as argument and returns an integer pointer
C
A pointer to a function that takes an integer pointer as an argument and returns an integer
D
A function that takes an integer pointer as an argument and returns a function pointer
       Programming       Declaration       ISRO-2017 May
Question 4 Explanation: 
→ int (*f) (int*); f is a pointer to a function that takes an integer pointer as an argument and returns an integer
→ int (*p)(char *a); p ia a pointer to a function that takes an argument as a pointer to a character and returns an integer.
Question 5
What will be the output of the following C code?
A
10 11 12 13 14
B
10 10 10 10 10
C
0 1 2 3 4
D
Compilation error
       Programming       Control Flow       ISRO-2017 May
Question 5 Explanation: 
Step-1: We are initialized i=0 in for loop. It means condition true because it is less than 5.
Step-2: Inside the for loop we are assigning again I value is 10 and printing value i.
Iteration-1: We are printing value 10 then increment by 1
Iteration-2: We are clearing previous value and assigning value 10. Printing value is 10;
Iteration-5: We are clearing previous value and assigning value 10. Printing value is 10
Step-3: output is 1010101010
Question 6
What does the following program do when the input is unsigned 16-bit integer?
A
It prints all even bits from num
B
It prints all odd bits from num
C
It prints binary equivalent of num
D
None of the above
       Programming       Control Flow       ISRO-2017 May
Question 6 Explanation: 
Step-1: Take n value initially 14(any number we can take but we are taken 14)
Step-2: 14<16
Step-3: It will print 00000000 00001110
Question 7
What is the output of the following program?
A
20 10 10
B
20 10 20
C
20 20 20
D
10 10 10
       Programming       Functions       ISRO-2017 May
Question 7 Explanation: 
Step-1: Every program starts execution from main() function.
Step-2: By default tmp value 20 will print initially.
Step-3: It calls fun() then it will print 10
Step-4: Again we are in main() function and printing value 20. Actually, the static value will return because its scope is a lifetime. But we are given tmp value as global. So, it prints 20 instead of 10.
Question 8
We use malloc and calloc for
A
Dynamic memory allocation
B
Static memory allocation
C
Both dynamic and static memory allocation
D
None of the above
       Programming       Calloc-Malloc       ISRO-2017 May
Question 8 Explanation: 
C -Dynamic memory allocation refers to performing manual memory management for dynamic memory allocation in the C programming language via a group of functions in the C standard library, namely
1. Malloc
2. Realloc
3. Calloc
4. Free.
Question 9
The complexity of the program is
A
O(log n)
B
O(n2)
C
O(n2 log n)
D
O(n log n)
       Programming       Control Flow       ISRO-2017 December
Question 9 Explanation: 
Question 10
What is the output of the following C program? #include<stdio.h> #define SQR(x) (x*x) int main() { int a; int b=4; a=SQR(b+2); printf("%d\n",a); return 0; }
A
14
B
36
C
18
D
20
       Programming       Macros       ISRO CS 2014
Question 10 Explanation: 
In the question, SQR is macro which is preprocessor statement in c language.
Here macro takes one parameter also.
A macro is a fragment of code that is given a name. You can use that fragment of code in your program by using the name. For example,
#define SQR(x) (x*x)
Here, when we use SQR(x) in our program, it's replaced with (x*x)
The movement program control execute the macro, it will replace SQR(b+2) by (b+2*b+2)
The expression (b+2*b+2) consists of addition and multiplication operators.
Between two operators multiplication operator has highest priority later addition .
So the expression evaluation steps are as follows
a = (b + 2*b + 2)
=(4+2*4+2)// first multiplication
=(4+8+2) // addition equal priority , so it will evaluate left to right
=(12+2)
=14
Question 11
Which of the following is true with respect to Reference?
A
A reference can never be NULL
B
A reference needs an explicit dereferencing mechanism
C
A reference can be reassigned after it is established
D
A reference and pointer are synonymous
       Programming       Pointers       ISRO CS 2014
Question 11 Explanation: 
In the C++ programming language, a reference is a simple reference data type that is less powerful but safer than the pointer type inherited from C. A reference is a general concept datatype, with pointers and C++ references being specific reference data type implementations.
We can assign NULL to pointers where as we can’t assign NULL to references.
We can re-assign pointers as many as number of times where a reference can never be re-assigned once it is established.
Question 12
Which of the following is the correct order of evaluation for the below expression?
z=x+y*z/4%2-1
A
*/%+-=
B
=*/%+-
C
/*%-+=
D
*%/-+=
       Programming       Operator       Nielit Scientist-B IT 4-12-2016
Question 12 Explanation: 
Here, *,/,% are having same priority. So, it executes follows first come first serve or left to write. +,- are having same priority. So, it executes follows first come first serve or left to write. = having least priority. It evaluates right to left.
Question 13
What is the meaning of following declaration?
int(*P[7])();
A
P is pointer to function
B
P is pointer to such function which return type is array
C
P is array of pointer to function
D
P is pointer to array of function
       Programming       Pointers       Nielit Scientist-B IT 4-12-2016
Question 13 Explanation: 
int *ptr[7]; --This is an array of 7 int* pointers, a pointer to an array of 7 ints
int (*ptr)[7]; --This is a pointer to an array of 7 int
int(*P[7])(); --P is array of pointer to function
int(*P)() ; --​ P is pointer to function
Question 14
The keyboard used to transfer control from a function back to the calling function is:
A
Switch
B
Go to
C
go back
D
Retun
       Programming       Functions       Nielit Scientist-B IT 4-12-2016
Question 14 Explanation: 
● The return statement terminates the execution of a function and it returns the control to the calling function.
● The execution resumes in the calling function at a point immediately following the call.
Question 15
An external variable
A
is globally accessible by all functions
B
has a declaration "extern" associated with it when declared within a function
C
will be initialized to 0 if not initialized
D
All of these
       Programming       Storage-Classes       Nielit Scientist-C 2016 march
Question 15 Explanation: 
An external variable can be accessed by all the functions in all the modules of a program. It is a global variable. For a function to be able to use the variable, a declaration or the definition of the external variable must lie before the function definition in the source code. Or there must be a declaration of the variable, with the keyword extern, inside the function.
Question 16
What will be the value of x and y after execution of the following statement (C language)
n=5;
x=n++;
y=-x;
A
5,-4
B
6,-5
C
6,-6
D
5,-5
       Programming       Operator       Nielit Scientist-C 2016 march
Question 16 Explanation: 
Given statements are n=5, x=n++ and y=-x.
N++ is post increment statement, so first “n” will store into variable into “x” and later “n” value is incremented.
X value becomes 5 and y value become -5.
Question 17
In C programming language, if the first and the second operands of operator + are of types int and float, respectively, the result be of type
A
int
B
float
C
char
D
long int
       Programming       Data-Type       Nielit Scientist-C 2016 march
Question 17 Explanation: 
Expressions don’t have a type. Expressions can result in a value which has a type.
The rules for implicit type casting are as follows:
Integer Promotion: All types below int, like char and short are converted to int.
If still types other than int remain, following rules are executed by order
● If long double exists, all are converted to long double.
● If double exists, all are converted to double.
● If float exists, all are converted to float, and so on.
Question 18
For x and y are variables as declared below double x=0.005, y=-0.01; what is the value of ceil(x+y), where is a function to compute ceiling of a number?
A
1
B
0
C
0.005
D
0.5
       Programming       Data-Type       Nielit Scientist-C 2016 march
Question 18 Explanation: 
x+y = 0.005-0.01 =-0.005
Description
CEIL(x) rounds the number x up.
Examples
CEIL(1.3) equals 2
CEIL(-1.6) equals -1
Question 19
To sort many large objects or structures, it would be most efficient to place
A
them in an array and sort the array
B
pointers to them in an array and sort the array
C
them in a linked list and sort the linked list
D
references to them in an array and sort the array
       Programming       Structure       Nielit Scientist-C 2016 march
Question 19 Explanation: 
● Pointers will point to large objects or structures.
● By using pointers we will easily access the large objects or structures with the help the addresses pointing to them.
● If you made any changes to the elements in the array, it automatically reflect as these are pointed by the pointers
Question 20
If initialization is a part of declaration of a structure, then storage class can be
A
automatic
B
register
C
static
D
anything
       Programming       Structure       Nielit Scientist-C 2016 march
Question 20 Explanation: 
Storage class specifiers available in C programming language include 'auto', 'register', 'static' and 'extern'.Depending upon the developer requirement , the storage class is anything.
Question 21

Consider the following pseudo-code fragment, where m is a non-negative integer that has been initialized:

     p = 0;
     k = 0;
     while(k < m)
           p = p + 2k;
           k = k + 1;
     end while

Which of the following is a loop invariant for the while statement?

(Note: a loop variant for a while statement is an assertion that is true each time guard is evaluated during the execution of the while statement).

Options:
A
p = 2k - 1 and 0≤k
B
p = 2k+1 - 1 and 0≤k
C
p = 2k - 1 and 0≤k≤m
D
p = 2k+1 - 1 and 0≤k≤m
       Programming       programming       UGC-NET DEC Paper-2
Question 21 Explanation: 
For k=0, P = 0+20 = 1
k=1, P = 1+21 = 3
k=2, P = 3+22 = 7
k=3, P = 7+23 = 15
Only the option-3 satisfied to the loop variant.
Ex: m=2, The loop will execute for 3 times for k value is 0,1 and 2.
Then options-3 gives P=1, P=3 and P=7 for the k values 0,1 and respectively.
Question 22

Consider the following method :

int f(int m, int n, boolean x, boolean y)
{
     int res=0;
     if(m<0) {res=n-m;}
     else if(x || y) {
                             res= -1;
                             if( n==m) { res =1; }
     }
     else {res=n; }
  return res;
} /*end of f */

If P is the minimum number of tests to achieve full statement coverage for f() and Q is the minimum number of tests to achieve full branch coverage for f(), then (P,Q) =

A
(3,4)
B
(3,2)
C
(2,3)
D
(4,3)
       Programming       Programming       UGC-NET DEC Paper-2
Question 22 Explanation: 
→ Code coverage is a measure which describes the degree of which the source code of the program has been tested.
→ Statement coverage is a white box test design technique which involves execution of all the executable statements in the source code at least once. It is used to calculate and measure the number of statements in the source code which can be executed given the requirements.
→ Branch coverage is a testing method, which aims to ensure that each one of the possible branch from each decision point is executed at least once and thereby ensuring that all reachable code is executed.
→ In the branch coverage, every outcome from a code module is tested. For example, if the outcomes are binary, you need to test both True and False outcomes.
Question 23
Let A be a square matrix of size nxn. consider the following program. What is the expected output?
C=100
for i=1 to n do
for j=1 to n do
{
 Temp=A[i][j]+C
 A[i][j]=A[j][i]
 A[j][i]=Temp-C
}
for i=1 to n do
for j=1 to n do
 output(A[i][j]);
A
The matrix A itself
B
Transpose of matrix A
C
Adding 100 to the upper diagonal elements and subtracting 100 from diagonal elements of A
D
None of the option
       Programming       Arrays       Nielit Scientist-B CS 22-07-2017
Question 23 Explanation: 
Question 24
What is the correct way to round off x, a float. to an int value?
A
y=(int)(x+0.5)
B
y=int(x+0.5)
C
y=(int)x+0.5
D
y=(int)(int) x+0.5)
       Programming       Type-Casting       Nielit Scientist-B CS 2016 march
Question 24 Explanation: 
Rounding off a value means replacing it by a nearest value that is approximately equal or smaller or greater to the given number.
y = (int)(x + 0.5); here x is any float value. To round off, we have to typecast the value of x by using (int)
Example:
#include
int main ()
{
float x = 3.6;
int y = (int)(x + 0.5);
printf ("Result = %d\n", y );
return 0;
}
Output:
Result = 4.
Question 25
What error would the following function given on compilation?
f(int a, int b)
{
int a;
a=20;
return a;
}
A
Missing parenthesis is return statement
B
Function should be defined as int f(int a, int b)
C
Redeclaration of a
D
None of these
       Programming       Compilation       Nielit Scientist-B CS 2016 march
Question 25 Explanation: 
We are already declared variable name ‘a’ in function. Again we are declared inside the function. So, the compiler will raise a error “Redeclaration of a”
Question 26
Prior to using a pointer variable it should be
A
declared
B
initialized
C
both declared and initialized
D
none of these
       Programming       Pointers       Nielit Scientist-B CS 2016 march
Question 26 Explanation: 
● In the programming, Before using any variable we should declare that variable.If require means initialize the variable.
● Pointer is also one variable
● So before using a pointer variable it should be both declared and initialized.
Question 27
Output of the following loop is for(putchar('c');putchar('a');putchar('r')) putchar('t');
A
a syntax error
B
cartrt
C
catrat
D
catratratratrat...
       Programming       Control Flow       Nielit Scientist-B CS 2016 march
Question 27 Explanation: 
Syntax of ‘for loop’
for(Initialization; Condition; value modification/updation)
As per the above question,
→ Initialization part given by putchar('c)
→ Condition part check by putchar('a')
→ Value modification/updation part given by putchar('r')
→ Inside the for loop we are given putchar('t’)
→ The sequence of the for loop first initialization, second condition, executing inside body of for loop and value modification.
So, it prints catratratratrat...
Question 28
If space occupied by two strings s1 and s2 in 'C' are respectively m and n, then space occupied by string obtained by concatenating s1 and s2 is always
A
less than m+n
B
equal to m+n
C
greater than m+n
D
none of these
       Programming       Strings       Nielit Scientist-B CS 2016 march
Question 28 Explanation: 
If space occupied by two strings s1 and s2 in 'C' are respectively m and n, then space occupied by string obtained by concatenating s1 and s2 is always less than m+n
Question 29
Consider the following pseudo-code fragment, where m is a non-negative integer that has been initialized:
p=0;
k=0;
while(k < m)
        p = p + 2k;
        k=k+1;
end while
Which of the following is a loop invariant for the while statement?
(Note: a loop variant for a while statement is an assertion that is true each time guard is evaluated during the execution of the while statement).
A
p = 2 k − 1 and 0≤k < m
B
p = 2 k+1 − 1 and 0≤k < m
C
p = 2 k − 1 and 0≤k≤m
D
p = 2 k+1 − 1 and 0≤k≤m
       Programming       Programming       UGC NET CS 2018-DEC Paper-2
Question 29 Explanation: 
For k=0, P=0+2​ 0​ =1
k=1, P=1+2​ 1​ =3
k=2,P=3+2​ 2​ =7
k=3,P=7+2​ 3​ =15
Only the option-3 satisfied to the loop variant.
Ex: m=2, The loop will execute for 3 times for k value is 0,1 and 2.
Then options-3 gives P=1,P=3 and P=7 for the k values 0,1 and respectively
Question 30
Consider the C/C++ function f() given below:
void f(char w [ ] )
{
int x = strlen(w); //length of a string
char c;
For (int i = 0; i < x; i++)
{
c = w[i];
w[i] = w[x - i - 1];
w[x - i - 1] = c;
}
}
Which of the following is the purpose of f() ?
A
It output the content of the array with the characters rearranged so they are no longer recognized a the words in the original phrase.
B
It output the contents of the array with the characters shifted over by one position.
C
It outputs the contents of the array in the original order.
D
It outputs the contents of the array in the reverse order.
       programming       programming       UGC NET CS 2018-DEC Paper-2
Question 30 Explanation: 
It outputs the contents of the array in the original order because it swaps pairs of elements at locations (i and x - i - 1) twice .
Question 31
What does the following java function perform ? (Assume int occupies four bytes of storage)
Public static int f(int a)
{
//Pre-conditions : a>0 and no overflow/underflow occurs
int b=0;
for(int i=0; i<32; i++)
{
b=b <<1;
b= b | (a & 1);
a = a >>> 1; // This is a logical shift
}
Return b;
}
A
Return the int that represents the number of 0’s in the binary representation of integer a.
B
Return the int that represents the number of 1’s in the binary representation of integer a.
C
Return the int that has the reversed binary representation of integer a.
D
Return the int that has the binary representation of integer a.
       Programming       Programming       UGC NET CS 2018-DEC Paper-2
Question 31 Explanation: 
→ Consider the a value is 5 .
The initial value of b is 0 and b<<1 means b will get value of 2
b=b|(a&1) which means 2|(5&1) then b will get value “2”
a=a<<1 means value a will reduce to 3
→ Repeat the above procedure for 31 iterations .
→ Iteration-2: b=b<<1 then b is 4 and b=b|(a&1)= 4|(3&1) then b is 5 and a becomes 1
→ Iteration-3: b=b<<1 then b is 10 and b=b|(1&1)= 4|(3&1) then b is 11 and a becomes 0
→ And this procedure will repeat until “i” value is 32.
→ The final value is 11 (Number of 1’s in the result is 2) and the number of 1’s in the input 5 are 2.
Question 32
Consider the following recursive Java function f that takes two long arguments and returns a float value :
public static float f(long m, long n)
{
float result = (float) m / (float) n;
if (m < 0 || n < 0)
return 0⋅0f;
else
result += f(m*2, n*3);
result result;
}
Which of the following integers best approximates the value of f(2,3) ?
A
0
B
3
C
1
D
2
       Programming       Programming       UGC NET CS 2018-DEC Paper-2
Question 32 Explanation: 
public static float f(long m, long n)
{
float result = (float) m / (float) n;
if (m < 0 || n < 0)
return 0⋅0f;
else
result += f(m*2, n*3);
result result;
}
function call→ f(2,3)
→ result=2.0/3.0
=0.666
if condition is false, else will be executed result = 0.666+f(4,9) function call→ f(4,9)
→ result=4.0/9.0
=0.444
result=0.4444+f(8,27)
function call→ f(8,27)
→ result=8.0/27.0
=0.2962
result=0.2962+f(16,54)
function call→ f(16,81)
→ result=16.0/81.0
=0.1975
result=0.1975+f(32,243)
function call→ f(32,243)
→ result= 32.0/243.0
= 0.13168
result=0.13168+f(64,729)
and so on
f(128,2187),f(256,6561),f(512,19683),f(1024,59049),f(2048,177147)
result=0.6666+0.4444+0.2962+0.1975+0.13168+0.08779+0.0390+0.026+0.0173+0.0115
The best approximate value is sum of all the function call result values which is equal 2.
Question 33
Consider the following method :
int f(int m, int n, boolean x, boolean y)
{
int res=0;
if(m<0) {res=n-m;}
else if(x || y) {
res= -1;
if( n==m) { res =1; }
}
else {res=n; }
return res;
} /*end of f */
If P is the minimum number of tests to achieve full statement coverage for f() and Q is the minimum number of tests to achieve full branch coverage for f(), then (P,Q) =
A
(3,4)
B
(3,2)
C
(2,3)
D
(4,3)
       Programming       Programming       UGC NET CS 2018-DEC Paper-2
Question 33 Explanation: 
→ Code coverage is a measure which describes the degree of which the source code of the program has been tested
→ Statement coverage is a white box test design technique which involves execution of all the executable statements in the source code at least once. It is used to calculate and measure the number of statements in the source code which can be executed given the requirements.
→ Branch coverage is a testing method, which aims to ensure that each one of the possible branch from each decision point is executed at least once and thereby ensuring that all reachable code is executed.
→ In the branch coverage, every outcome from a code module is tested. For example, if the outcomes are binary, you need to test both True and False outcomes.
Question 34

What will be output if you will compile and execute the following C code?

void main()

{

char c=125;

c=c+10;

printf("%d",c);

}
A
135
B
115
C
-121
D
-8
       Programming       Compilation       Nielit Scientist-B CS 4-12-2016
Question 34 Explanation: 
As we know any data type shows cyclic properties
In our example the data type is char data type , so if you will increase or decrease the char
variables beyond its maximum or minimum value respectively it will repeat same value
according to following cyclic order
So,
125+1= 126
125+2= 127
125+3=-128
125+4=-127
125+5=-126
125+6=-125
125+7=-124
125+8=-123
125+9=-122
125+10=-121
Question 35

What will be output if you will compile and execute the following C code?

void main()

{

printf("%d",sizeof(5.2));
}
A
4
B
8
C
2
D
16
       Programming       Compilation       Nielit Scientist-B CS 4-12-2016
Question 35 Explanation: 
Size of is a special operator will return number of bytes of data types. By default system will take integer data type,if we are not specifying any data type. Total size is 4 bytes.
Question 36
Output of following program
#include
int main()
{
int i=5;
printf("%d%d%d", i++,i++,i++);
return 0;
}
A
765
B
567
C
777
D
compile dependent
       Programming       Control Flow       Nielit Scientist-B IT 22-07-2017
Question 36 Explanation: 
● Multiple increment or decrement of same variable in one expression or one statement is compiler dependent.
● The output will depend upon the way the compiler developed.
Question 37
Output of following program?
#include
void dynamic(int s,..)
{
printf("%d",s);
}
int main()
{
dynamic(2,4,6,8);
dynamic(3,6,9);
return 0;
}
A
23
B
compile error
C
43
D
32
       Programming       Functions       Nielit Scientist-B IT 22-07-2017
Question 37 Explanation: 
● The latest compiler giving compilation error ​ “error: expected declaration specifiers or ‘...’ before ‘.’ toke​ n“
● Old compiler may support that syntax, in that syntax only first argument is defined which consists of remainings arguments but not defined.
● For the function call dynamic(2,4,6,8), first argument 2 is printed.
● For the function call dynamic(3,6,9);first argument 3 is printed.
Question 38
Output of following program?
#include
int main()
{
int *ptr;
int x;
ptr=&x;
*ptr=0;
printf("x=%d\n",x);
printf("*ptr=%d\n",*ptr);
*ptr+=5;
printf("x=%d\n",x);
printf("*ptr=%d\n",*ptr);
(*ptr)++;
printf(x=%d\n",x);
printf("*ptr=%d\n",*ptr);
return 0;
}
A
x=0
*ptr=0
x=5
*ptr=5
x=6
*ptr=6
B
x=garbage value
*ptr=0
x=garbage value
*ptr=5
x=garbage value
*ptr=6
C
x=0
*ptr=0
x=5
*ptr=5
x=garbage value
*ptr=garbage value
D
x=0
*ptr=0
x=0
*ptr=0
x=0
*ptr=0
       Programming       Pointers       Nielit Scientist-B IT 22-07-2017
Question 38 Explanation: 
● ptr=&x; // Address of x variable will store in to pointer “ptr” or pointer “ptr” will point to “x”
● *ptr=0; // storing value “0” in the memory location.
● printf("x=%d\n",x); // “0” will be printed
● printf("*ptr=%d\n",*ptr); // “0” will be printed because , ptr will point to variable “x”
● *ptr+=5; // *ptr+=5; means *ptr=*ptr+5 which is nothing but value 5 will store into memory locaton
● printf("x=%d\n",x); // 5 will be printed
● printf("*ptr=%d\n",*ptr); //5 will be printed.
● (*ptr)++; // (*ptr) means 5 and it is incremented by 1 so the updated value is “6”
● printf(x=%d\n",x); // “6” will be printed
● printf("*ptr=%d\n",*ptr);// “6” will be printed
Question 39
Assume that float takes 4 bytes, predict the output of following program.
#include
int main()
{
float arr[5]={12.5,10.0,13.5,90.5,0.5};
float *ptr1=&arr[0];
float *ptr2=ptr1+3;
printf("%f",*ptr2);
printf("%d",ptr2-ptr1);
return 0;
}
A
90.500000 3
B
90.500000 12
C
10.000000 12
D
0.500000 3
       Programming       Pointers       Nielit Scientist-B IT 22-07-2017
Question 39 Explanation: 
● float *ptr1=&arr[0]; // ptr1 will point to first element of the array.
● float *ptr2=ptr1+3; // ptr2 will point to fourth element of the array
● printf("%f",*ptr2); // It will display fourth element value which is 90.500000
● printf("%d",ptr2-ptr1); // Here both pointer will point to same array . The subtraction operation gives the number of elements between the addresses.
Question 40
Assume that size of an integer is 32 bit. What is the output of following ANSI C program?
#include
struct st
{
int x;
static int y;
};
int main()
{
printf(%d",sizeof(struct st));
return 0;
}
A
4
B
8
C
compile error
D
runtime error
       Programming       Structure       Nielit Scientist-B IT 22-07-2017
Question 40 Explanation: 
● It will be compile error-​ “error: expected specifier-qualifier-list before ‘static’ static int y;”
● Static variables are allocated memory in data segment, not stack segment.
● Static variable isn't allowed in struct because C requires the whole structure elements to be placed "together". To withdraw a element value from a structure is counted by the offset of the element from the beginning address of the structure.
Question 41
Consider the following C declaration
Struct
{
short s[5];
Union
{
float y;
long z;
}u;
}t;
Assume that objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes respectively. The memory requirement for variable t ignoring alignment considerations, is
A
22 bytes
B
14 bytes
C
18 bytes
D
10 bytes
       Programming       Structure       Nielit Scientist-B IT 22-07-2017
Question 41 Explanation: 
Union
{
float y;
long z;
}u;
● The sizeof union is 8 bytes (maximum size of two variables sizes 4 and 8)
● The size of structure is sum of short size(array of 5 elements) is 5x2=10 and union size is 8.
● So the total size is 18.
Question 42
#include
struct st
{
int x;
struct st next;
};
int main()
{
struct st temp;
temp.x=10;
temp.next=temp;
printf("%d",temp.next,x);
return 0;
}
A
Compile error
B
10
C
Runtime Error
D
Garbage value
       Programming       Structure       Nielit Scientist-B IT 22-07-2017
Question 42 Explanation: 
● We can’t declare structure member of own type with in the structure.
● But we can declare pointer structure member with in same structure which is called self referential structure.
● The above code gives compile error ​ “ ​ main.c:5:11: error: field ‘next’ has incomplete type struct st next”
Question 43
cross product is a
A
Unary operator
B
ternary operator
C
binary Operator
D
Not an operator
       Programming       Operator       Nielit Scientist-B IT 22-07-2017
Question 43 Explanation: 
● The cross product of two tables A x B builds a huge virtual table by pairing every row of A with every row of B.
● This operator requires two tables so it binary operator.
Question 44

Which of the following numerical values is NOT a valid constant in C language?

A
12345L
B
018CDF
C
9.3e12
D
0XBCF
       Programming       Data-Type       JT(IT) 2018 PART-B Computer Science
Question 44 Explanation: 
→ 12345L integer long is valid integer
→ 018CDF starts with 0 means octal number but actually we are given decimal and hexa numbers. So it is not a valid constant.
→ 9.3e12 float number
→ 0XBCF is hexa number. Valid constant.
Question 45

Consider the following algorithm:

Algorithm Anand(n)
{
          sum=0;
          For i=1 to n do
          {
                 For j=1 to i do
                 {
                        sum=sum+i;
                 }
           }
}

What will be the output of this algorithm for n=10?

A
370
B
385
C
380
D
55
       Programming       Control Flow       JT(IT) 2018 PART-B Computer Science
Question 45 Explanation: 

Step-1: if i=1, j is also will execute 1 time because it is purely dependent to the variable i.
Sep-2: The sum variable is perform addition how many time jth loop executes with the difference of i value.
Question 46

In C language ______ is a process in which a function calls itself repeatedly until some specified condition has been satisfied

A
Infinite loop
B
Call by value
C
Call by reference
D
Recursion
       Programming       Functions       JT(IT) 2018 PART-B Computer Science
Question 46 Explanation: 
Recursion is a process in which a function calls itself repeatedly until some specified condition has been satisfied.
Question 47

What is the return value of the C library function fmod(d1,d2), where d1 and d2 are integer numbers?

A
It returns the remainder of d2/d1, with the same sign as d1
B
It returns the remainder of d2/d1, with the same sign as d2
C
It returns the remainder of d1/d2, with the same sign as d1
D
It returns the remainder of d1/d2, with the same sign as d2
       Programming       Control Flow       JT(IT) 2018 PART-B Computer Science
Question 47 Explanation: 
Mod operations: fmod(d1,d2)
Take d1 = 10 and d2 = 20
d1/d2 = 10/20 = 10
So, option C is correct.
Question 48

Which of the following ‘C’ language operators has the right to left associativity?

A
Relational operators
B
Conditional operators
C
Logical AND and OR operators
D
Arithmetic multiply and divide operators
       Programming       Operator       JT(IT) 2018 PART-B Computer Science
Question 48 Explanation: 
Logical AND and OR operators are having right to left associativity.
Question 49
What will be the output of following?
main()
{
static int a=3;
printf("%d",a--);
if(a)
main();
}
A
3
B
3 2 1
C
3 3 3
D
Program will fall in continuous loop and print 3
       Programming       Storage-Classes       Nielit Scientific Assistance IT 15-10-2017
Question 49 Explanation: 
The variable is static variable, the value is retained during multiple function calls. Initial value is 3
“A--” is post decrement so it will print “3”
if(2) condition is true and main() function will call again , Here the “a” value is 2.
“A--” is post decrement so it will print “2”
if(1) condition is true and main() function will call again Here the “a” value is 1.
“A--” is post decrement so it will print “1”
if(0) condition is false it won’t call main() function
Question 50
The following program fragment prints
int i=5;
do
{
putchar(i+100);
printf("%d",i--);
}
while(i);
A
i5h4g3f2el
B
14h3g2f1e0
C
An error message
D
None of the above
       Programming       Control Flow       Nielit Scientific Assistance IT 15-10-2017
Question 50 Explanation: 
Here, i=5 and putchar(i+100) it means actually putchar(5+100) ⇒ putchar(105);
It will print the ASCII equivalent of 105 which is lower case ' i '. The printf statement prints the current value of i. i.e. 5 and then decrements it. So, h4 will be printed in the next pass. This continues until ' i ' becomes 0, at which point the loop gets terminated.
Question 51
Consider the following declaration
int a, *b=&a, **c=&b;
a=4;
**c=5;
If the statement
b=(int *)**c
is appended to the above program fragment then
A
Value of b becomes 5
B
value of b will be the address of c
C
value of b is unaffected
D
none of these
       Programming       Pointers       Nielit Scientific Assistance IT 15-10-2017
Question 51 Explanation: 
In the given program fragment, three variables are there
Ordinary variable -a // value will be stored
Pointer variable -b // address of variable will be stored
Pointer to pointer variable(double pointer) -c // address of pointer variable will stored.
a=4 means storing/assigning value to “a”.
**c means value at(value at(c)) =value at(value at(&b)) (c holds address of pointer “b”)
=value at(&a) (b holds the address of “a”)
Memory location of variable “a”, value 5 is
stored/assigned into the variable.
Given statement is b=(int *)**c. So the value of b becomes 5.
Question 52
Consider the following code segment in C++. How many times the for loop will be repeated?
int main()
{
int f=1;
for(;f;)
cout<<”f=”<<f++<<”\n”;
Return 0;
}
A
10 times
B
Not even once
C
Repeated forever
D
Only once
       Programming       Control Flow       KVS 22-12-2018 Part-B
Question 52 Explanation: 
There is no termination condition for the loop and value “f” incremented every time. So it will execute infinite number of times.
Question 53
Consider the following code segment:
int x=22,y=15;
x=(x>y)?(x+y):(x-y);
What will be the value of x after the code is executed?
A
22
B
37
C
7
D
37 and 7
       Programming       Operator       KVS 22-12-2018 Part-B
Question 53 Explanation: 
The condition 22>15 is true so it will execute 22+15 which is 37
Question 54
In the context of while loop do while loop in C++, which of the following is not true?
A
Both the loops are repetitive in nature
B
Boh are conditional loops
C
Both will be executed at least once
D
Both are terminated when the condition become false
       Programming       Control Flow       KVS 22-12-2018 Part-B
Question 54 Explanation: 
Do-while will execute at least one time while loop will execute minimum of zero times.
Question 55
Consider the code segment written below in C++:
if (count<10) //if#1
if((count%4)==2) //if#2
count<<”condition:white\n”;
else //(indentation is wrong)
count<<”condition is:tan\n”;
There are 2 if statements and one else. To which if, the else statement belong?
A
It belongs to if#1
B
It belongs to if#2
C
It belongs to both the if statements
D
It is independent
       Programming       if-else       KVS 22-12-2018 Part-B
Question 55 Explanation: 
→ The else statement belongs its immediate previous if statement.
→ If there are no braces ({}) following the if statement then only the next immediate statement belongs to the if statement. The same thing is true for else and else-if clause
Question 56
The following program fragment prints
int i=5;
do
{
putchar(i+100);
printf("%d",i--);
}while(i);
A
i5h4g3f2el
B
14h3g2f1e0
C
An error message
D
None of the above
       Programming       Control Flow       Nielit Scientific Assistance CS 15-10-2017
Question 56 Explanation: 
Step-1: putchar(105) will print the ASCII equivalent of 105 is ' i '.
Step-2: The printf statement prints the current value of i=5 because we are given post decrement.
Step-3: The same process will perform until it fail the condition.
Question 57
What will be the value of C, in C=x++ + ++x + ++x + x, if x=10?
A
48
B
45
C
46
D
49
       Programming       Operator       KVS DEC-2013
Question 57 Explanation: 
→ Incrementing the same variable multiple times with in the same expression is abnormal behaviour. Multiple compiler gives different outputs.
→ The initial value of “x” is 10 and it is pre-incremented two times and later addition will be performed from left to right.
→ While performing the addition the variable “x” value is 12 and we adding four “x” variables so answer is 48 (output is based upon the Gcc compiler)
Question 58
Consider the following code segment
if(Y<0)
{
X=-X;
Y=-Y;
}
Z=0;
while(Y>0)
{
Z=Z+X;
Y=Y-1;
}
Assume that X,Y and Z are integer variables, and that X and Y have be initialized. Which of the following best describes what this code segment does?
A
Sets Z to be the product X*Y
B
Sets Z to be the sum X+Y
C
Sets Z to be the absolute value of Y
D
Sets Z to be the value of Y
       Programming       Control Flow       KVS DEC-2017
Question 58 Explanation: 
Assume X=3 and Y=3
So, it satisfying condition while(Y>0)
Iteration-1: while(3>0)
Z=0+3⇒ Z=3
Y=3-1⇒ Y=2
Iteration-2: while(2>0)
Z=3+3=6
Y=2-1=1
Iteration-3:while(1>0)
Z=6+3
Y=1-1=0
Iteration-4 while(0>0) fails.
So,It Sets Z to be the product X*Y=3*3=9
Question 59
In structured programming, a program is decomposed into modules. Coupling and Cohesion describe the characteristics of modules. A good decomposition should attempt to
A
Minimize coupling and minimize cohesion
B
Maximize coupling and minimize cohesion
C
Minimize coupling and maximize cohesion
D
Maximize coupling and maximize cohesion
       Programming       Coupling-and-Cohesion       KVS DEC-2017
Question 59 Explanation: 
→ In order to maximize cohesion, make sure you are always able to summarize the purpose of a single module in a single phrase.
→ If it turns out to be impossible to capture the purpose of a module into a single discriminative phrase, then that's a smell.
→ At the other hand, don't go totally overboard by making everything a separate module.
→ It will have a dramatic effect on the number of dependencies between modules, and therefore hurt you in terms of coupling.
→ One of the tools that might help you organizing your dependencies is the Dependency Structure Matrix.
Question 60
In C++, which of the following statements correctly returns the memory from the dynamic array pointer PP to the free store?
A
delete pp;
B
delete pp[]
C
delete []pp;
D
delete *pp;
       Programming       Arrays       KVS DEC-2017
Question 60 Explanation: 
The "free store is just another name of heap. It is an area of memory that is used for dynamic allocation of memory while the program is running(i.e., at run time). Dynamic allocation of memory from the heap allows us to create,use and dispose of objects as needed. It allows us to grow and shrink dynamic data structure(Eg:Linked list,tree,graphs) while the program executes. there is no distinction between the "free store" and the heap. they refer to the same thing.
Question 61
Assume X and Y are non zero positive integers. Consider the following pseudo code
fragment:
while X< >Y do
if X > Y then
X ← X-Y
else
Y← Y-X
endif
end while
print(X)
What is the code doing?
A
It computes the GCD of two numbers
B
It computes the LCM of two numbers
C
It finds the smallest of two numbers
D
It divides the largest number by the smaller
       Programming       Control Flow       KVS DEC-2017
Question 61 Explanation: 
Let X=3 and Y=5
1​ st​ pass : X=3 and Y=2
2​ nd​ pass : X=1 and Y=2
3​ rd​ pass : X=1 and Y=1
Write(X), which writes 1. Which is nothing but GCD of 3 & 5.
Question 62
A condition that is caused by run time error in a computer program is known as
A
Exception
B
Syntax error
C
Semantic error
D
Fault
       Programming       Compilation       KVS DEC-2017
Question 62 Explanation: 
● An exception is an abnormal or unprecedented event that occurs after the execution of a software program or application. It is a runtime error of an undesired result or event affecting normal program flow.
● An exception is also known as a fault.
Question 63

Which of the following method is used for repetitive in which each action is started in terms of a previous result:

A
Recursion
B
Iteration
C
Looping
D
Structures
       Programming       Recursion       JT(IT) 2016 PART-B Computer Science
Question 63 Explanation: 
→ Recursion is the process of repeating items in a self-similar way. In programming languages, if a program allows you to call a function inside the same function, then it is called a recursive call of the function.
Question 64
What is the following program segment doing?
main()
{
int d=1;
do
{
printf(“%d”\n”,d++);
}while(d<=9);
}
A
Adding 9 integers
B
Adding integers from 1 to 9
C
Displaying integers from 1 to 9
D
No output
       Programming       Control Flow       KVS 30-12-2018 Part B
Question 64 Explanation: 
The code consists of do-while loop in which action performs first and later condition checking.
In the printf() statement, d++ means first it will display d value and increment the d value later condition checking.So the integer values 1 to 9 will be printed.
Question 65
What shall be the output of the following program in C++(using turbo C++)?
#include<iostream.h>
float answer;
main()
{
answer=⅓;
cout<<”The value of ⅓ is” <<answer,,”\n”;
return(0);
}
A
The value of ⅓ is 0
B
The value of ⅓ is 0.33
C
The value of ⅓ is 0.3333
D
The value of ⅓ is 1/3
       Programming       C++       KVS 30-12-2018 Part B
Question 65 Explanation: 
The expression answer=⅓ , which is integer divide by integer operation .
Modulus operation gives the quotient values when one number is divided by another number .
When 1 is divide by 3, the quotient is o
Question 66
What shall be the output of the following code segment in C++?
int main()
{
int x=0,i=4;
switch(i)
{
default:x+=5;
cout<<”x=<<x<<”\n”;
Case 4:x+=4;
cout<<”x=<<x<<”\n”;
Case 1:x+=1;
cout<<”x=<<x<<”\n”;
Case 2:x+=2;
cout<<”x=<<x<<”\n”;
Case 3:x+=3;
cout<<”x=<<x<<”\n”;
}
return 0;
}
A
x=4,x=10
B
x=4
C
x=10
D
x=9
       Programming       Switch-Case       KVS 30-12-2018 Part B
Question 66 Explanation: 
The output of the above program is x=4,x=5,x=7 and x=10 as there is no break statement is the switch case. From the above options the possible values are 4 and 10 only.
Question 67
Consider the following code segment in C++;
value=1;
result=(value++ *5)+(value++ *3)
What shall be the answer, after this code is executed?
A
result=11 or 13
B
result=16 or 19
C
result=21 or 16
D
result=19 or 21
       Programming       Operator       KVS 30-12-2018 Part B
Question 67 Explanation: 
→If the one variable incremented multiple time in single expression , it gives abnormal behaviour .
→Consider the following expression, result=(value++ *5)+(value++ *3), post increements operation will be performed in the expression.
→result=(value++ *5)+(value++ *3) First left side operand evaluates means (1*5+2*3)=11
→result=(value++ *5)+(value++ *3) First right side operand evaluates means (2*5+1*3)=13
Question 68
Data members which are static
A
Cannot be assigned a value
B
Can only be used in static functions
C
Cannot be defined in a union
D
Can be accessed outside the class
       Programming       Storage-Classes       KVS 30-12-2018 Part B
Question 68 Explanation: 
→When we declare a normal variable (data member) in a class, different copies of those data members create with the associated objects.
→In some cases when we need a common data member that should be same for all objects, we cannot do this using normal data members. To fulfill such cases, we need static data members.
→If you are calling a static data member within a member function, member function should be declared as static (i.e. a static member function can access the static data members)
Question 69
In VB, which of the following arithmetic operators has the highest level of precedence?
A
+ -
B
* /
C
^(exponentiation)
D
MOD
       Programming       Operator       KVS 30-12-2018 Part B
Question 69 Explanation: 
^(exponentiation) operator has highest precedence than arithmetic operators
Question 70
The following ‘C’ statement : int *f [ ] ( ); declares:
A
A function returning a pointer to an array of integers.
B
Array of functions returning pointers to integers.
C
A function returning an array of pointers to integers.
D
An illegal statement.
       Programming       Programming       UGC NET CS 2016 Aug- paper-2
Question 70 Explanation: 
int *f [ ] ( ); It declares array of functions returning pointers to integers.
Question 71
Given i = 0, j = 1, k = –1 x = 0.5, y = 0.0 What is the output of the following expression in C language ?
x * y < i + j || k
A
-1
B
0
C
1
D
2
       Programming       Programming       UGC NET CS 2016 July- paper-2
Question 71 Explanation: 
x * y < i + j || k
Step-1: Evaluate x * y because multiplication has more priority than remaining operators
x * y→ 0
Step-2: i + j is 1
Step-3: (x*y) < (i+j) is 1. Because relational operators only return 1(TRUE) or 0(FALSE).
Step-4: ((x*y) < (i+j)) || k is logical OR operator.
1 || -1 will returns 1.
Note: The precedence is ((x*y) < (i+j)) || k
Question 72
What is the value returned by the function f given below when n = 100?
int f (int n)
{
if (n = = 0) then return n;
else return n + f(n-2);
}
A
2550
B
2556
C
5220
D
5520
       Programming       Programming       UGC NET CS 2016 July- paper-2
Question 72 Explanation: 
Given n=100
Step-1: int f(100)
{ if (100 = = 0) then return 100; /*false*/
else return 100 + f(100-2); /* return 198 */
}
Step-2: int f(98)
{ if (98 = = 0) then return 98; /*false*/
else return 98 + f(96); /* return 194 */
}
Step-3: int f(96)
{ if (96 = = 0) then return 96; /*false*/
else return 96 + f(94); /* return 190 */
}
;
;
Step-final:
int f(0)
{ if (0 = = 0) then return 0; /*TRUE*/
else return 0 + f(0); /* FALSE */
}
Actual process:
The above series is nothing but sum of Arithmetic Progression(A.P)
= 2+4+6+8+ ... +98+100
= n(n+1)
/* It is nothing but sum of even numbers upto 'n' */
= 50*51
= 2550
Question 73
Consider the following program :
#include
main( )
{
int i, inp;
float x, term=1, sum=0;
scanf(“%d %f ”, &inp, &x);
for(i=1; i<=inp; i++)
{
term = term * x/i;
sum = sum + term ;
}
printf(“Result = %f\n”, sum);
}
The program computes the sum of which of the following series?
A
x + x​ 2​ /2 + x​ 3​ /3 + x​ 4​ /4 +...
B
x + x​ 2​ /2! + x​ 3​ /3! + x​ 4​ /4! +...
C
1 + x​ 2​ /2 + x​ 3​ /3 + x​ 4​ /4 +...
D
1 + x​ 2​ /2! + x​ 3​ /3! + x​ 4​ /4! +...
       Programming       Programming       UGC NET CS 2015 Dec- paper-2
Question 73 Explanation: 
In this problem, we have to find series of evaluation.
Let x=5, inp=5
Iteration-1:
for(i=1; i<=inp; i++)
/* condition true 1<=5 */
{
term = term * x/i;
/* (1*5)/1=5. Here, 5 nothing but ‘x’ */
sum = sum + term ; /* 0+5=5 */
}
Iteration-2: Here, ‘i’ becomes 2.
for(i=2; i<=inp; i++)
/* condition true 2<=5 */
{
term = term * x/i;
/* (5*5)/2 is nothing but x​ 2​ /i */
sum = sum + term ; /* 5+12=17 */
}
;;;
;;;
Iteration-5: Here, ‘i’ becomes 5.
for(i=5; i<=inp; i++)
/* condition true 5<=5 */
{
term = term * x/i;
/* (625*5)/5! is nothing but x​ 5​ /i! */
sum = sum + term ;
}
So, Option-B is correct answer.
Question 74
What is the output of the following program?
(Assume that the appropriate preprocessor directives are included and there is no syntax error)
main( )
{
char S[ ] = "ABCDEFGH";
printf ("%C", *(&S[3]));
printf ("%s", S+4);
printf ("%u", S);
/* Base address of S is 1000 */
}
A
ABCDEFGH1000
B
CDEFGH1000
C
DDEFGHH1000
D
DEFGH1000
       Programming       Arrays       UGC NET CS 2015 Jun- paper-2
Question 74 Explanation: 
Step-1: String is stored in appropriate location is

Step-2: printf ("%C", *(&S[3]));
This statement will print character ‘D’
(&S[3]) → Will print address of index 3
*(&S[3]) → will print value in index 3. The value is nothing but ‘D’.
Step-3: printf ("%s", S+4); /* will print characters ‘EFGH’ */
Because previous S value index position is 3. Now we are performing +4 operations. It will print EFGH. we are given escape sequence is String.
Step-4: printf ("%u", S); → It will print address of S. The base address given as S is 1000.
Question 75
Given that x = 7.5, j = -1.0, n = 1.0, m = 2.0
the value of --x + j == x>n>=m is:
A
0
B
1
C
2
D
3
       Programming       Operator       UGC NET CS 2015 Jun- paper-2
Question 75 Explanation: 
Step-1: Given data, x = 7.5, j = -1.0, n = 1.0, m = 2.0
given condition is --x + j == x > n >= m
(6.5 + (-1.0)) == ((6.5 > 1.0) >= 2.0)
Here, 6.5 is greater than 1.0. so, it will print TRUE value is 1
Step-2: (5.5 == (1 >= 2.0))
Here, 1 is less than 2.0. So, it will print FALSE value is 0
Step-3: 5.5 == 0
5.5 is not equal to 0. So, it will print FALSE value is 0.
Question 76
Suppose x and y are two Integer Variables having values 0x5AB6 and 0x61CD respectively. The result (in hex) of applying bitwise operator and to x and y will be :
A
0 x 5089
B
0 x 4084
C
0 x 78A4
D
0 x 3AD1
       Programming       Operator       UGC NET CS 2004 Dec-Paper-2
Question 76 Explanation: 
Given two integer numbers are 0x5AB6 and 0x61CD
Step-1: Convert hexadecimal numbers into binary number because we want to perform AND operation.
0x5AB6 equivalent into binary number is 0101 1010 1011 0110
0x61CD equivalent into binary number is 0110 0001 1100 1101
Step-2: Perform Bitwise AND operation
0101 1010 1011 0110
0110 0001 1100 1101
-----------------------------
0100 0000 1000 0100(Bitwise AND operation)
------------------------------
Step-3: Convert result into hexadecimal number.
0100 0000 1000 0100 equivalent into hexadecimal number is 0x4084
Question 77
Consider the following statements,
int i=4, j=3, k=0;
k= ++i- - -j + i++ - - - j +j++;
What will be the values of i, j and k after the statement.
A
7, 2, 8
B
5, 2, 10
C
6, 2, 8
D
4, 2, 8
       Programming       Operator       UGC NET CS 2004 Dec-Paper-2
Question 77 Explanation: 
Given values are i=4, j=3 and k=0
Step-1: k= ++i- --j + i++ - --j +j++;
k= 5 - 2 + 5 - 1 + 1
k= (5-2)+(5-1)+1
= 3 + 4 + 1
= 8
Step-2: The value of i=6,j=2 and k=8
Question 78
What is the value of the arithmetic expression (Written in C) 2*3/4-3/4*2
A
0
B
1
C
1.5
D
None of the above
       Programming       Operator       UGC NET CS 2004 Dec-Paper-2
Question 78 Explanation: 
Given expression is 2*3/4-3/4* 2
Step-1: In C language multiplication and division having higher priority than addition and subtraction.
Step-2: Evaluating procedure is ((2*3)/4)-((3⁄4)* 2)
= ((2*3)/4)-((3⁄4)* 2)
= (6/4)-((3⁄4)* 2)
= 1 - ((3⁄4)* 2)
= 1 - 0*2
= 1 - 0
= 1
Question 79
What is the output of the following C-program
main()
{
printf(''%d%d%d'', sizeof(3.14f), sizeof(3.14), sizeof(3.141));
}
A
4 4 4
B
4 8 10
C
8 4 8
D
8 8 8
E
None of the above
       Programming       Operator       UGC NET CS 2005 Dec-Paper-2
Question 79 Explanation: 
The sizeof operator will print number of bytes of a data type.
sizeof(3.14f) → It will consider as float data type. The float data type size is 4 bytes.
sizeof(3.14) → It will consider as double data type. The double data type size is 8 bytes.
sizeof(3.141) → It will consider as double data type. The double data type size is 8 bytes.
Output= 4 8 8
Note: The exact size of each of these 3 types depends on the C compiler implementation (or) platform
Question 80
The bitwise OR of 35 with 7 in C will be :
A
35
B
7
C
42
D
39
       Programming       Operator       UGC NET CS 2005 Dec-Paper-2
Question 80 Explanation: 
Step-1: First we have to convert into binary numbers
(35)​ 10​ = (​ 0010 0011​ ) ​ 2
(7)​ 10​ = (0000 0111)​ 2
Step-2: Perform OR operation on both binary numbers.
0010 0011
0000 0111
---------------
0010 0111
----------------
Step-3: Convert result into Decimal number
(0010 0111)​ 2​ = (39)​ 10
Question 81
​ What will be the value of i for the following expression : int i=11, i=3 ; i+=(f >3) ? i & 2:5 ;
A
2
B
5
C
13
D
12
       Programming       Operator       UGC NET CS 2005 Dec-Paper-2
Question 81 Explanation: 
Let assume f=11 and i=3
i=i+(11>3) ? 3&2 : 5
/* 11>3 condition true. So, it will perform 3&2
(3)10 → (11)2
(2)10 → (10)2
----
10 (AND)
----
(10)2 = (2)10
So, i=3+2
i=5
Note: Instead of ‘f’ they given ‘i’ value in question. Excluded for evaluation.
Question 82
After 3 calls of the c function bug( ) below, the values of i and j will be :
int j=1;
bug( )
{
static int i=0; int j=0;
i++;
j++;
return (i);
}
A
i = 0, j = 0
B
i = 3, j = 3
C
i = 3, j = 0
D
i = 3, j = 1
       Programming       Storage-Classes       UGC NET CS 2005 june-paper-2
Question 82 Explanation: 
Step-1: Initially i=0 but given as static. The scope is lifetime.
Step-2: Call-1: i=1 and j=1
Call-2: i=2 and j=1 because ‘i’ is static ‘j’ is again become 0 when it starts new call.
Call-3: i=3 and j=1 because ‘i’ is static ‘j’ is again become 0 when it starts new call.
Note: A static ‘int’ variable remains in memory while the program is running.
Question 83
Find the output of the following “C” code :
main ( )
{
int x=20, y=35;
x= y++ + x++;
y= ++y + ++x;
printf (“%d, %d\n”, x,y);
}
A
55, 93
B
53, 97
C
56, 95
D
57, 94
E
56, 93
       Programming       Operator       UGC NET CS 2005 june-paper-2
Question 83 Explanation: 
Step-1: Here, we are using post increment for both x and y. In post increment the value assign first and update after assigning.
x= 35 + 20
y= 37 + 56 (In this statement, ‘y’ will become 36 before performing pre increment)
Step-2: Final x=56 and y=93
Note: They given wrong options. We are added correct option.
Excluded for evaluation.
Question 84
main( )
{
char *str = “abcde”;
printf (“%c”, *str);
printf (“%c”, *str++);
printf (“%c”, *(str++));
printf (“%s”, str);
}
The output of the above ‘C’ code will be :
A
a a c b c d e
B
a a c c c d e
C
a a b c d e
D
None of these
       Programming       Operator       UGC NET CS 2005 june-paper-2
Question 84 Explanation: 
The above program we are using post increment operators. In post increment the value assign first and update after assigning.
main( )
{
char *str = “abcde”;
printf (“%c”, *str); /* It returns character ‘a’ */
printf (“%c”, *str++); /* It returns character ‘a’ because it is used post increment*/
printf (“%c”, *(str++)); /* It returns character ‘b’ because the previous increment is update here and present also they given post increment, so it only returns ‘b’ */
printf (“%s”, str); /* It returns aabcde */
}
Question 85
When a function is recursively called, all automatic variables :
A
are initialized during each execution of the function
B
are retained from the last execution
C
are maintained in a stack
D
are ignored
       Programming       Functions       UGC NET CS 2006 Dec-paper-2
Question 85 Explanation: 
→ When a function is recursively called, all automatic variables are initialized during each execution of the function. → Automatic local variables primarily applies to recursive lexically-scoped languages. An automatic variable is a local variable which is allocated and deallocated automatically when program flow enters and leaves the variable's scope. The scope is the lexical context, particularly the function or block in which a variable is defined.
Question 86
Enumeration variables can be used in :
A
search statement like an integer variable
B
break statement
C
preprocessor commands
D
function statement
       Programming       Data-Type       UGC NET CS 2006 Dec-paper-2
Question 86 Explanation: 
→ Enumeration variables can be used in search statement like an integer variable.
→ The enumerator names are usually identifiers that behave as constants in the language. An enumerated type can be seen as a degenerate tagged union of unit type. A variable that has been declared as having an enumerated type can be assigned any of the enumerators as a value.
→ In ‘C’ language exposes the integer representation of enumeration values directly to the programmer. Integers and enum values can be mixed freely, and all arithmetic operations on enum values are permitted. It is even possible for an enum variable to hold an integer that does not represent any of the enumeration values.
Question 87
int arr[ ]={1, 2, 3, 4}
int count;
incr( )
{
return ++count;
}
main( )
{
arr[count++]=incr( );
printf(“arr[count]=%d\n”, arr[count]);
}
The value printed by the above program is ​ :
A
1
B
2
C
3
D
4
       Programming       Arrays       UGC NET CS 2006 Dec-paper-2
Question 87 Explanation: 
Step-1: Before printing the arr[count] value, the variable “count” is incremented twice then count =2
Step-2: arr[2] value is 3 , So, it will print the value “3”.
Method-2:
→ The function incr() is executed as it is first statement.
→ Count is global variable whose initial value is 0 ,the function definition increments the count value and returns value “1” to the main function.
→ Again the main function, the expression arr[count++] , here count variable operation is post increment so arr[1] will store the value “1”.
→ After that statement , count value becomes “2” as it is incremented in the previous statement (total two increments).
→ Before printing the arr[count] value, the variable “count” is incremented twice then count =2
→ arr[2] value is 3 , so it will print the value “3”.
Question 88
When one-dimensional character array of unspecified length is assigned an initial value :
A
an arbitrary character is automatically added to the end of the string
B
‘0’ is added to the end of the string
C
length of the string is added to the end of the string
D
‘end’ is added to the end of the string
       Programming       Arrays       UGC NET CS 2006 Dec-paper-2
Question 88 Explanation: 
→ String literals are stored in ‘C’ as an array of chars, terminated by a null byte. A null byte is a char having a value of exactly zero, noted as '\0'.
→ When one-dimensional character array of unspecified length is assigned an initial value ‘0’ is added to the end of the string.
Question 89
The declaration “unsigned u” indicates :
A
u is an unsigned character
B
u is an unsigned integer
C
u is a character
D
u is a string
       Programming       Data-Type       UGC NET CS 2006 Dec-paper-2
Question 89 Explanation: 
The declaration “unsigned u” indicates u is an unsigned integer.
Question 90
What is the output of the following program segment ?
main ( )
{
int count, digit=0;
count=1;
while(digit <=9)
{
printf(​"%d /n”" , ++count);
++digit;
}
}
A
10
B
9
C
12
D
11
       Programming       Control-Statement       UGC NET CS 2006 June-Paper-2
Question 90 Explanation: 
The digit starts with 0 and will run 9 more times. It means, the loop will run 10 runs. The count variable we are given pre increment. So, it increments before assigning values.
It prints the result is
2 /n 3 /n 4 /n 5 /n 6 /n 7 /n 8 /n 9 /n 10 /n 11
Question 91
A static variable is one :
A
Which cannot be initialized
B
Which is initialized once at the commencement of execution and cannot be changed at runtime
C
Which retains its value throughout the life of the program
D
Which is the same as an automatic variable but is placed at the head of a program
       Programming       Storage-Classes       UGC NET CS 2006 June-Paper-2
Question 91 Explanation: 
A static variable is one which retains its value throughout the life of the program. The static storage class instructs the compiler to keep a local variable in existence during the life-time of the program instead of creating and destroying it each time it comes into and goes out of scope.
Question 92
If the following loop is implemented
{
int num=0;
do
{
- - num;
printf (​ ”%d”​ , num);
num++;
} while (num >50)
}
A
the loop will run infinitely many times
B
the program will not enter the loop
C
there will be compilation error reported
D
a run time error will be reported
       Programming       Control-Statement       UGC NET CS 2006 June-Paper-2
Question 92 Explanation: 
It will run infinite number of times because the --num variable is keep on reducing amount and num++ variable is keep on increasing amount. So, it never violate condition.
Question 93
# define max(x, y) x=(x > y) ?x :y is a macro definition, which can find the maximum of two numbers x and y if :
A
x and y are both integers only
B
x and y are both declared as float only
C
x and y are both declared as double only
D
x and y are both integers, float or double
       Programming       Macros       UGC NET CS 2006 June-Paper-2
Question 93 Explanation: 
→ The C preprocessor is a macro preprocessor (allows you to define macros) that transforms your program before it is compiled.
→ A macro is a fragment of code that is given a name. You can use that fragment of code in your program by using the name. For example,
→ #define c 299792458 // speed of light
→ Here, when we use c in our program, it's replaced with 299792458.
→ From the given question, the x and y consists of any data type.
Question 94
The function sprintf( ) works like printf( ), but operates on:
A
Data in a file
B
stdrr
C
stdin
D
string
       Programming       Strings       UGC NET CS 2006 June-Paper-2
Question 94 Explanation: 
Syntax:
int sprintf ( char * str, const char * format, ... );
Composes a string with the same text that would be printed if format was used on printf, but instead of being printed, the content is stored as a C string in the buffer pointed by str.
Question 95
What will be the output of the following ‘C’ code ?
main( )
{
int x=128;
printf (“\n%d”, 1 + x++);
}
A
128
B
129
C
130
D
131
       Programming       Programming       UGC NET CS 2014 Dec-Paper-2
Question 95 Explanation: 
In this program we are using post increment. Post increment will send the value before updating the value.
printf(“\n%d”, 1 + x++); /* x=128 */
Here, 1+128=129
Question 96
What does the following expression means ? char *(*(*a[N]) ( )) ( );
A
a pointer to a function returning array of n pointers to function returning character pointers.
B
a function return array of N pointers to functions returning pointers to characters
C
an array of n pointers to function returning pointers to characters
D
an array of n pointers to function returning pointers to functions returning pointers to characters.
       Programming       Programming       UGC NET CS 2014 Dec-Paper-2
Question 96 Explanation: 
char *(*(*a[N]) ( )) ( ); /* an array of n pointers to function returning pointers to functions returning pointers to characters */
Question 97
Consider an array A[20, 10], assume 4 words per memory cell and the base address of array A is 100. What is the address of A[11, 5] ? Assume row major storage.
A
560
B
565
C
570
D
575
       Programming       Arrays       UGC NET CS 2014 Dec-Paper-2
Question 97 Explanation: 
Here, Row major order generally follows offset formula to find address of the location.
Offset= (Row number * Total number of columns) + Column Number
Step-1: Add the Base address to calculate the effective address. Given matrix is A[20][10], Size of memory word is 4 bytes, address of the location to find A[11][5], Base address is 100.
Step-2: Offset = (11*10) + 5
= 115 (multiply with 4 words)
= 115*4
= 460
Step 3: Initial base address is 100
=Offset+base address
= 460 +100
= 560.
Question 98
What is the size of the following Union ? Assume that the size of int = 2, size of float = 4, size of char = 1

     union tag {

     int a;

     float b;

     char c;

     };

A
2
B
4
C
1
D
7
       Programming       Structure       UGC NET CS 2013 Sep-paper-2
Question 98 Explanation: 
Union: The compiler allocates the memory by considering the size of the largest memory. So, size of union is equal to the size of largest member
union tag
{
int a; /* It takes only 2 bytes */
float b; /* It takes only 4 bytes */
char c; /* It takes only 1 bytes */
};
As per the definition of union will take 4 bytes of memory. Because float having highest size among all.
Question 99
Assume that x and y are non-zero positive integers. What does the following program segment perform ? while (x!=0) { if (x>y)     x = x-y;     else      y=y-x; printf(“%d”,x); }
A
Computes LCM of two numbers
B
Computes GCD of two numbers
C
Divides large number with small number
D
Subtracts smaller number from large number
       Programming       Control-Statement       UGC NET CS 2013 Sep-paper-2
Question 99 Explanation: 
Let X=3 and Y=5
1st pass : X=3 and Y=2
2nd pass : X=1 and Y=2
3rd pass : X=1 and Y=1
Write(X), which writes 1.
Which is nothing but GCD of 3 & 5.
Question 100
Consider the following program segment :

d=0;

for(i=1; i<31, ++i)

for(j=1; j<31, ++j)

for(k=1; k<31, ++k)

if ((i+j+k)%3)= = 0);

d = d + 1;

printf(“%d”, d);

The output will be

A
9000
B
3000
C
90
D
2700
       Programming       Control-Statement       UGC NET CS 2013 Sep-paper-2
Question 100 Explanation: 
Step1: Each for loop will execute 30 times, then total number of iterations are 30*30*30=27000,
But value “d” is incremented only factors of 3 only.
Step2: For the values i=1, j=1 then
k=1,4,7,10,13,16,19,22,25 and 28(10 times)
i=1 and j=2 then
k=3,6,9,12,15,18,21,24,27,and 30(10 times)
i=1 and j=3 then
K=2,5,8,11,14,17,20,23,26,29(10 times)
Then for i=1 value there will be 30*10 =300 times.
Finally for all “i” values from 1 to 30 is
= 300*30
= 9000
Question 101
Enumeration is a process of
A
Declaring a set of numbers
B
Sorting a list of strings
C
Assigning a legal values possible for a variable
D
Sequencing a list of operators
       Programming       Data-Type       UGC NET CS 2012 Dec-Paper-2
Question 101 Explanation: 
→ Enumeration is a data type consisting of a set of named values called elements, members, enumeral, or enumerators of the type.
→ Enumeration is a process of assigning a legal values possible for a variable
Question 102
What is the result of the following expression? (1 & 2) + (3 & 4)
A
1
B
3
C
2
D
0
       Programming       Operator       UGC NET CS 2012 Dec-Paper-2
Question 102 Explanation: 
Given statement, (1&2)+(3/4)
(1&2) means (1 AND 2)
(¾) means (3 divided by 4)
Step-1: First consider (1&2)

Question 103
What is the output of the following ‘C’ program ? (Assuming little - endian representation of multi-byte data in which Least Significant Byte (LSB) is stored at the lowest memory address.)
#include
#include
/* Assume short int occupies two bytes of storage */
int main ( )
{
union saving
{
short int one;
char two[2];
};
union saving m;
m.two [0] = 5;
m.two [1] = 2;
printf(’’%d, %d, %d\n”, m.two [0], m.two [1], m.one);
}/* end of main */
A
5, 2, 1282
B
5, 2, 52
C
5, 2, 25
D
5, 2, 517
       Programming       Structure       UGC NET CS 2018 JUNE Paper-2
Question 103 Explanation: 
● m.two[0] holds the value 5 and m.two[1] holds the value 2 So it will print 5 and 2 values.
● Size of the short integer is 2 bytes. Saving is union variable, we will access one variable at time and only one memory location is shared among all the members.So the two values 5 and 2 (two bytes of the data) will store in little endian format in the variable m.one.
● Endianness is the sequential order in which bytes are arranged into larger numerical values when stored in memory or when transmitted over digital links.
● In big-endian format, whenever addressing memory or sending/storing words bytewise, the most significant byte—the byte containing the most significant bit—is stored first (has the lowest address) or sent first, then the following bytes are stored or sent in decreasing significance order,
● Little-endian format reverses this order: the sequence addresses/sends/stores the least significant byte first (lowest address) and the most significant byte last (highest address).
● First 5 will store in the lowest address and 2 will store next highest address.
● So the binary representation 5 and 2 in little endian format is 00000010 00000101
The binary number of the above is 517
Question 104
Given below are three implementations of the swap( ) function in C++ :

Which of these would actually swap the contents of the two integer variables p and q ?
A
(a) only
B
(b) only
C
(c) only
D
(b) and (c) only
       Programming       Functions       UGC NET CS 2018 JUNE Paper-2
Question 104 Explanation: 
Module -(a) is call by value , so by using that code w can not swap the contents.
Module -(b) is call by reference , So the modification of content in the function reflects the changes in the main program. Swapping is done in the module -(b).
Module -(c) is passing addresses as parameters but in the functions definition , We are changing the addresses not the content So swapping of the values can’t be done.
Question 105
Which of the following statements is/are True ?
P : C programming language has a weak type system with static types.
Q : Java programming language has a strong type system with static types.
A
P only
B
Q only
C
Both P and Q
D
Neither P nor Q
       Programming       Storage-Classes       UGC NET CS 2018 JUNE Paper-2
Question 105 Explanation: 
→ A strongly typed language has stricter typing rules at compile time, which implies that errors and exceptions are more likely to happen during compilation. Most of these rules affect variable assignment, return values and function calling.
→ A weakly typed language has looser typing rules and may produce unpredictable results or may perform implicit type conversion at runtime
→ Java, C#, Ada and Pascal are sometimes said to be more strongly typed than C, a claim that is probably based on the fact that C supports more kinds of implicit conversions, and C also allows pointer values to be explicitly cast while Java and Pascal do not.
→ Java itself may be considered more strongly typed than Pascal as manners of evading the static type system in Java are controlled by the Java virtual machine's type system.
→ C# and VB.NET are similar to Java in that respect, though they allow disabling of dynamic type checking by explicitly putting code segments in an "unsafe context".
→ Pascal's type system has been described as "too strong", because the size of an array or string is part of its type, making some programming tasks very difficult
Question 106
What does the following declaration mean ?          int (*ptr) [10];
A
ptr is an array of pointers of 10 integers.
B
ptr is a pointer to an array of 10 integers.
C
ptr is an array of 10 integers.
D
none of the above.
       Programming       Arrays       UGC NET CS 2013 Dec-paper-2
Question 106 Explanation: 
int (*ptr) [10]; It means ‘ptr’ is a pointer to an array of 10 integers.
Question 107
Which of the following has compilation error in C ?
A
int n=32 ;
B
char ch=65 ;
C
float f=(float)3.2 ;
D
none of the above
       Programming       Compilation       UGC NET CS 2013 Dec-paper-2
Question 107 Explanation: 
Option-A: ‘n’ is a integer value and and value of ‘n’ is 32.
Option-B: ‘ch’ is a character variable and value of ‘ch’ is 65.
Option-C: ‘f’ is a floating point variable and it uses type casting.
Option-D is correct answer.
Question 108
The correct way to round off a floating number x to an integer value is
A
y = (int) (x + 0.5)
B
y = int (x + 0.5)
C
y = (int) x + 0.5
D
y = (int) ((int)x + 0.5)
       Programming       Type-Casting       UGC NET CS 2013 Dec-paper-2
Question 108 Explanation: 
Here, with the help of type casting method we can round off a floating number x to integer value.
→ Type casting is a way to convert a variable from one data type to another data type.
Question 109
_______ is often used to prove the correctness of a recursive function.
A
Diagonalization
B
Communitivity
C
Mathematical Induction
D
Matrix Multiplication
       Programming       Functions       UGC NET CS 2013 Dec-paper-2
Question 109 Explanation: 
→ Mathematical Induction is often used to prove the correctness of a recursive function.
→ Mathematical Induction is a special way of proving things. It has only 2 steps:
Step-1: Show it is TRUE for the first one
Step-2: Show that if any one is TRUE then the next one is true
Then all are true
Question 110
Which of the following metric does not depend on the programming language used ?
A
Line of code
B
Function count
C
Member of token
D
All of the above
       Programming       Properties       UGC NET CS 2012 June-Paper2
Question 110 Explanation: 
Function count does not depend on the programming language used. It only counts number of functional entries in the function.
Lines of code (LOC) is a software metric used to measure the size of a computer program by counting the number of lines in the text of the program's source code.
Question 111
printf(“%c”, 100);
A
prints 100
B
prints ASCII equivalent of 100
C
prints garbage
D
none of the above
       Programming       ASCII       UGC NET CS 2012 June-Paper2
Question 111 Explanation: 
printf(“%c”, 100); → It prints ASCII equivalent of 100.
→ It prints character ‘b’.
Question 112
X – = Y + 1 means
A
X = X – Y + 1
B
X = –X – Y – 1
C
X = –X + Y + 1
D
= X – Y – 1
       Programming       Operator       UGC NET CS 2011 Dec-Paper-2
Question 112 Explanation: 
In Programming languages like C,C++ and Java we can write X-=Y+1 into X=X-Y+1
Note: X*=Z+1 → X=X*Z+1
X/=Z+1 → X=X/Z+1
X+=Z+1 → X=X+Z+1
Question 113
Consider the function
find (int x, int y)
{return ((x < y) ? 0 : (x - y)) ; }
Let a, b be two non-negative integers. The call find {a, find(a, b)} can be used to find the
A
maximum of a, b
B
positive difference of a, b
C
sum of a, b
D
minimum of a, b
       Programming       Functions       NIELIT Technical Assistant_2016_march
Question 114
When the following code is executed what will be the value of x and y ? int x = 1, y = 0;      y = x++;
A
2,1
B
2,2
C
1,1
D
1,2
       Programming       Operator       UGC NET CS 2013 June-paper-2
Question 114 Explanation: 
Given post increment for x value. In post increment the value assign first and update after assigning.
So, x=2 and y=1
Question 115
How many values can be held by an array A(–1,m;1,m) ?
A
m
B
m2
C
m(m+1)
D
m(m+2)
       Programming       Arrays       UGC NET CS 2013 June-paper-2
Question 115 Explanation: 
int A[n] means "n" elements and index starts from 0 to n-1.
→ Similarly, int A[n][n] means both column and rows has "n" elements and total elements are n*n nothing but n2 elements.
In the given example ,an array A(-1,m;1,m)
→ In which rows indexes are -1,0,1,2, and so on up to m then total rows are "m+2".
→ columns consist of 1,2,3 and so on up to m then total elements in columns are "m".
Total elements are (m+2)*m
Question 116
What is the result of the expression (1&2)+(3/4) ?
A
1
B
2
C
3
D
0
       Programming       Operator       UGC NET CS 2013 June-paper-2
Question 116 Explanation: 
Given statement, (1&2)+(3/4)
(1&2) means (1 AND 2)
(¾) means (3 divided by 4)
Step-1: First consider (1&2)

Question 117
How many times the word ‘print’ shall be printed by the following program segment ?
for (i=1, i≤2,i++)
for (j=1,j≤2,j++)
for(k=1,k≤2,k++)
printf("print/n")
A
1
B
3
C
6
D
8
       Programming       Control-Statement       UGC NET CS 2013 June-paper-2
Question 117 Explanation: 
Iteration-1: In iteration-1 of ith loop will execute once and jth loop 2 times.
Each jth loop will execute kth loop 2 times.
Finally, iteration-1 will display 4 times of “print/n” word.
Iteration-2: In iteration-2 of ith loop will execute once and jth loop 2 times.
Each jth loop will execute kth loop 2 times.
Finally, iteration-2 will display 4 times of “print/n” word.
Above code segment will print 8 times.
Better understanding purpose given modified code segment:
#include
int main()
{
int i,j,k,jj=0,kk=0,ii=0;
for(i=1;i<=2;i++)
{
ii++;
for(j=1;j<=2;j++)
{
jj++;
for(k=1;k<=2;k++)
{
kk++;
printf("print/n");
}
}
}
printf("ii=%d \t jj=%d \t kk=%d",ii,jj,kk);
return 0;
}
Output:
print/n print/n print/n print/n print/n print/n print/n print/n
ii=2 jj=4 kk=8
Question 118
How many of the following declarations are correct ?
int z = 7.0;
double void = 0.000;
short array [2] = {0, 1, 2};
char c = “\n”;
A
None
B
One is correct
C
Two are correct
D
All four are correct
       Programming       Data-Type       UGC NET CS 2010 Dec-Paper-2
Question 118 Explanation: 
int z = 7.0; → Incorrect. Given data type is integer but given floating point number. It is wrong declaration.
double void = 0.000; → Incorrect. void is a keyword but can’t use with variable declaration.
It always return null value.
short array [2] = {0, 1, 2}; → Correct. It is right format. We can declare static values here itself.
char c = “\n”; → Incorrect. It is character data type but given in double quotes. It should be single quote instead of double quote.
Question 119
Which one of the following will set the value of y to 5 if x has the value 3, but not otherwise ?
A
if (x = 3) y = 5
B
if x = = 3 (y = 5)
C
if (x = = 3); y = 5
D
if (x = = 3) y =5
       Programming       Operator       UGC NET CS 2010 Dec-Paper-2
Question 119 Explanation: 
Here, they given two conditions
1. x has the value of 3 and
2. y value should be 5
Step-1: Based on the conditions, option-A is wrong because they are assign the 3 value to x but x is equals to 3.
Step-2: Option-B they given x==3 and y=5 but we have to give parenthesis to x condition.
Step-3: Option-C they given syntax error by using ;
Step-4: Option-D is the correct representation to above 2 conditions.
Question 120
Which one of the following sentences is true ?
A
The body of a while loop is executed at least once.
B
The body of a do ... while loop is executed at least once.
C
The body of a do ... while loop is executed zero or more times.
D
A for loop can never be used in place of a while loop.
       Programming       Control-Statement       UGC NET CS 2010 Dec-Paper-2
Question 120 Explanation: 
Syntax: do
{
Statement-1;
Statement-2;
}while(condition)
Here, without checking condition, it enters into loop. It means it executes at least once irrespective of condition.
Question 121
The statement
printf(“%d”,10 ? 0 ? 5 : 1 : 12);
will print
A
10
B
0
C
12
D
1
       Programming       Operator       UGC NET CS 2010 June-Paper-2
Question 121 Explanation: 
We can write above statement into (10 ? (0 ? 5 : 1) : 12)
Step-1: (0 ? 5 : 1) → It will give result 1 because the condition is FALSE because given value is 0. If nonzero given in condition, it will print TRUE value.
Step-2: (10 ? 1 : 12) → Here, given condition is nonzero. So, it will print TRUE value. The TRUE value is 1.
Note: Ternary operators(?:) evaluation starts from innermost conditions first.
Question 122
What will be the output of the following c-code ?
void main ( )
{
char *P = "ayqm" ;
char c;
c = ++*p ;
printf ("%c", c);
}
A
a
B
c
C
b
D
q
       Programming       Operator       UGC NET CS 2010 June-Paper-2
Question 122 Explanation: 
Pointer "p" will point to the string "ayqm",
*p means the first character of the string which is "a"
++*p means an increment of "a" which is nothing but "b"
printf ("%c", c); means the character "b" will be printed as output.
Note: They given syntax error in program.
Question 123
What is the value of ‘b’ after the execution of the following code statements : c=10; b=+ +c+ + +c;
A
20
B
22
C
23
D
None
       Programming       Operator       UGC NET CS 2009-June-Paper-2
Question 123 Explanation: 
It will give error message because they are not given in proper syntax. Suppose when we are taken (++c)+(++c);
→ It will give result 23 because pre/post increment will evaluate from right to left.
(++c)+(++c); /* It will increment by one. It means 11 */
(++c)+(++c); /* Before c=11 and now we are incrementing by 1. It will become 23. */
Question 124
Which of the following does not represent a valid storage class in ‘c’ ?
A
automatic
B
static
C
union
D
extern
       Programming       Storage-Classes       UGC NET CS 2009-June-Paper-2
Question 124 Explanation: 
→ Storage classes are auto,static,register an extern.
→ Union is not a storage class.
Question 125
What would be the output of the following program, if run from the command line as “myprog 123”?
main(int argc,char∗argv[ ])
{
int i;
i=argv[1] + argv[2] + argv[3];
printf (“%d”, i);
}
A
123
B
6
C
Error
D
“123”
       Programming       Command-Line-Arguements       UGC NET CS 2009 Dec-Paper-2
Question 125 Explanation: 
The input given in string type. But we need to print the value in integer type. For this we have to use type casting (or) atoi function. So, it will give output is “error”
Note: argv[1], argv[2] and argv[3] is string type.
Question 126
Which one of the following describes correctly a static variable ?
A
It cannot be initialised
B
It is initialised once at the commencement of execution and cannot be changed at run time
C
It retains its value during the life of the program
D
None of the above
       Programming       Storage-Classes       UGC NET CS 2008 Dec-Paper-2
Question 126 Explanation: 
A static variable is a variable that has been allocated "statically", meaning that its lifetime (or "extent") is the entire run of the program.
Question 127
The output of the program code
main( )
{
int x=0;
while(x<=10)
for ( ; ; )
if(++x % 10 = = 0 )
break;
print f(“x=%d”, x);
}
A
x=1
B
compilation error
C
x=20
D
None of the above
       Programming       Control-Statement       UGC NET CS 2008 Dec-Paper-2
Question 127 Explanation: 
main( )
{
int x=0;
while(x<=10) /* Here, the loop will run 10 times */
for ( ; ; ) /* It is dependent loop of while. So, it will also run 10 times */
if(++x % 10 = = 0 )
break;
printf(“x=%d”, x); /* Finally ‘x’ value will print 20 */
}
Note: Without for loop, it will print ‘x’ value only 10 times.
Question 128
When a language has the capability to produce new data types, it is said to be :
A
extensible
B
encapsulated
C
overloaded
D
none of the above
       Programming       Data-Type       UGC NET CS 2008 Dec-Paper-2
Question 128 Explanation: 
When a language has the capability to produce new data types, it is said to be extensible.
Question 129
What is the effect of the following C code ?
for(int i=1; i≤5; i=i+½)
         printf(“%d,”,i);
A
It prints 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, and stops
B
It prints 1, 2, 3, 4, 5, and stops
C
It prints 1, 2, 3, 4, 5, and repeats forever
D
It prints 1, 1, 1, 1, 1, and repeats forever
       Programming       Control-Statement       UGC NET CS 2008-june-Paper-2
Question 129 Explanation: 
According to integer datatype, fraction values we are not considering. So,it will always become
1. Iteration-1: for(int i=1; i≤5; i=i+½) /*condition TRUE, then we are printing value but incrementing by 0. It means, i=1+0 */
So, ‘i’ value always become 1 only. The given condition always TRUE and will print infinite times.
Question 130
Consider the following declaration in C :
char a[ ];
char *p;
Which of the following statement is not a valid statement ?
A
p=a;
B
p=a+2;
C
a=p;
D
p=&a[2];
       Programming       Pointers       UGC NET CS 2008-june-Paper-2
Question 130 Explanation: 
According to pointer value assigning declarations,
p=a; /*It is correct declaration */
p=p+2; /*It is correct declaration */
p=&a[2]; /*It is correct declaration */
a=p; /* It is incorrect declaration */
Question 131
Consider the following C code :
{
 int a=5, b=9;
float r;
r=b/a;
}
What is the value of r ?
A
1.8
B
1.0
C
2.0
D
0.0
       Programming       Data-Type       UGC NET CS 2008-june-Paper-2
Question 131 Explanation: 
Given ‘a’ and ‘b’ variables are integer data types.
‘r’ is floating point data type.
r=9/5; /* 9/5=1 but not 1.8 */
According to integer data type values will return only integers but not fraction.
So, ‘r’ is floating point value, it will assign fraction part 6 digits. it will print 1.000000
Question 132
Which of the following is true ?
A
A “static” member of a class cannot be inherited by its derived class.
B
A “static” member of a class can be initialized only within the class it is a member of.
C
A “static” member of a class can be initialized before an object of that class is created.
D
Since “static” member of a class is actually a global element, it does not require a class/object qualifier to access it independently of class/object.
       Programming       Storage-Classes       UGC NET CS 2008-june-Paper-2
Question 132 Explanation: 
FLASE: A “static” member of a class cannot be inherited by its derived class.
FALSE: A “static” member of a class can be initialized only within the class it is a member of.
TRUE: A “static” member of a class can be initialized before an object of that class is created.
FALSE: Since “static” member of a class is actually a global element, it does not require a class/object qualifier to access it independently of class/object.
Question 133
What cannot replace ‘?’ in the following C-code to print all odd numbers less than 100 ?
for (i=1; ? ; i=i+2)
   printf(“%d\n”,i);
A
i≤100
B
i≤101
C
i<100
D
i<101
       Programming       Control-Statement       UGC NET CS 2007-Dec-Paper-2
Question 133 Explanation: 
The given constraint in question, we have to print odd numbers in less than 100.
So, the condition should not be greater than 100 but it is equal to 100 acceptable.
for (i=1; i<=100 ; i=i+2)
printf(“%d\n”,i);
Question 134
Which of the following is a valid C code to print character ‘A’ to ‘C’ ?
A
x=’A’;
switch(x)
{ case ‘A’=printf (“%d\n”, x);
....
case ‘C’=printf (“%d\n”, x);
}
B
x=’A’;
switch(x)
{ case ‘A’<=x <=’C’; printf (“%d\n”, x); }
C
x=’A’;
switch(x)
{
case ‘A’ : printf (“%d\n”, x); break;
case ‘B’ : printf (“%d\n”, x); break;
case ‘C’ : printf (“%d\n”, x); break;
}
D
x=’A’;
switch(x)
{
case ‘A’=printf (“%d\n”, x);
case ‘B’=printf (“%d\n”, x);
case ‘C’=printf (“%d\n”, x);
}
E
None of the above
       Programming       Switch-Case       UGC NET CS 2007-Dec-Paper-2
Question 134 Explanation: 
→ The options A,B and D are syntactically incorrect.
→ Option C will print only one character "A"
→ All four options are invalid according to the question.
Question 135
The following loop in ‘C’ :
int i=0;
while (i++ < 0)
i-- ;
A
will terminate
B
will go into an infinite loop
C
will give compilation error
D
will never be executed
       Programming       Control-Statement       UGC NET CS 2007 June-Paper-2
Question 135 Explanation: 
#include
void main()
{
int i=0;
while(i++ < 0)
{
i--;
printf("%d",i);
}
}
/* It will terminate null value */
Question 136
What is the output of the following ‘C’ program ?
main( )
{
printf (“%x”, -1>>4);
}
A
ffff
B
Offf
C
OOOO
D
fffO
       Programming       Operator       UGC NET CS 2007 June-Paper-2
Question 136 Explanation: 

Question 137
Let A[1...n] be an array of n distinct numbers. If i < j and A[i] > A[j], then the pair (i, j) is called an inversion of A. What is the expected number of inversions in any permutation on n elements ?
A
θ(n)
B
θ(lgn)
C
θ(nlgn)
D
θ(n2)
       Programming       Arrays       UGC NET CS 2016 July- paper-3
Question 137 Explanation: 
→ Count of number of times the inner loop of insertion sort executes is actually equal to number of inversions in input permutation a1,a2,…an. Since for each value of i=1..n, j take the value 1..i−1, which means for every j < i it checks if a [ j ] > a [ i ] .

→ In any given permutation, maximum number of inversions possible is n(n-1)/2 which is O(n2). It is the case where the array is sorted in reverse order.

→ To resolve all inversions i.e., worst case time complexity of insertion sort is Θ(n2).

→ However, as per the question the number of inversions in input array is restricted to n.

→ The worst case time complexity of insertion sort reduces to Θ(n).
There are 137 questions to complete.
PHP Code Snippets Powered By : XYZScripts.com