TCS - D4-S2
TCS - D4-S2
- Ninja
Sub-Topic (Example: name of college)
MCQs
Question 1
Neelam wants to share her code with a colleague, who may modify
it. Thus she wants to include the date of the program creation, the
author and other she wants to include the date of the program
creation, the author and other information with the program. What
component should she use?
A Header Files
)
B Iteration
)
C Comments
)
D Preprocessor Directive
)
A Header Files
)
B Iteration
)
C Comments
)
D Preprocessor Directive
)
Ans: C
Question 2
What is the output of the following code statements? The compiler
saves the first integer at the memory location 4165 and the rest at
consecutive memory spaces in order of declaration. Integer is one
byte long.
integer a
pointer c, d
a = 30c = &a
c = &a
d = c
a = a + 10
print *c
A 30
)
B 4165
)
C 40
)
D 4166
)
A 30
)
B 4165
)
C 40
)
D 4166
)
Ans: C
Question 3
A data type is stored as an 6 bit signed integer. Which of the
following cannot be represented by this data type?
A 0
)
B 32
)
C 18
)
D 64
)
Question 3
A data type is stored as an 6 bit signed integer. Which of the
following cannot be represented by this data type?
A 0
)
B 32
)
C 18
)
D 64
)
Ans: B
Question 4
A language has 28 different letters in total. Each word in the
language is composed of maximum 7 letters. You want to create a
data-type to store a word of this language. You decide to store the
word as an array of letters. How many bits will you assign to the
data-type to be able to store all kinds of words of the language
A 7
)
B 35
)
C 28
)
D 196
)
A 7
)
B 35
)
C 28
)
D 196
)
Ans: B
Question 5
A 10-bit unsigned integer has the following range
A 0 to 1000
)
B 0 to 1024
)
C 0 to 1025
)
D 0 to 1023
)
Question 5
A 10-bit unsigned integer has the following range
A 0 to 1000
)
B 0 to 1024
)
C 0 to 1025
)
D 0 to 1023
)
Ans: D
Question 6
Parul takes as input two numbers: a and b. a and b can take integer
values between 0 and 255. She stores a, b and c as 1-byte data
type. She writes the following code statement to process a and b
and put the result in c.
c = a + 2*b
To her surprise her program gives the right output with some input
values of a and b, while gives an erroneous answer for others. For
which of the following inputs will it give a wrong answer?
Question 6
Parul takes as input two numbers: a and b. a and b can take integer
values between 0 and 255. She stores a, b and c as 1-byte data
type. She writes the following code statement to process a and b
and put the result in c.
c = a + 2*b
To her surprise her program gives the right output with some input
values of a and b, while gives an erroneous answer for others. For
which of the following inputs will it give a wrong answer?
A a=10 b=200
)
B a=200 b=10
)
C a=50 b=100
)
D a=100 b=50
)
A a=10 b=200
)
B a=200 b=10
)
C a=50 b=100
)
D a=100 b=50
)
Ans: A
Question 7
Which is used to convert source code to target language?
A Linker
)
B Compiler
)
C Executer
)
D Loader
)
Question 7
Which is used to convert source code to target language?
A Linker
)
B Compiler
)
C Executer
)
D Loader
)
Ans: B
Question 8
Tricha wants to store a list of binary data. Which of following data
types should she use?
A Integer
)
B Float
)
C Character
)
D Boolean
)
Question 8
Tricha wants to store a list of binary data. Which of following data
types should she use?
A Integer
)
B Float
)
C Character
)
D Boolean
)
Ans: D
Question 9
Which of the following options is an exception to being a part of
composite data types?
A Union
)
B Array
)
C Structure
)
D Stack
)
Question 9
Which of the following options is an exception to being a part of
composite data types?
A Union
)
B Array
)
C Structure
)
D Stack
)
Ans: D
Question 10
The data type is store as 6 but unsigned integer. Which of the
following can't be represented by the this data type:
A -12
)
B 0
)
C 32
)
D 18
)
Question 10
The data type is store as 6 but unsigned integer. Which of the
following can't be represented by the this data type:
A -12
)
B 0
)
C 32
)
D 18
)
Ans: A
Question 11
What is the difference between a function and a method?
Ans: A
Question 12
getc() returns EOF when
Ans: C
Question 13
What is the term given to the variable whose scope is beyond all
the scopes i.e., it can be accessed by all the scopes?
A Universal Variable
)
B Global Variable
)
C External Variable
)
D Auto Variable
)
Question 13
What is the term given to the variable whose scope is beyond all
the scopes i.e., it can be accessed by all the scopes?
A Universal Variable
)
B Global Variable
)
C External Variable
)
D Auto Variable
)
Ans: B
Question 14
Consider the following code:
B 40
)
C 32
)
D 72
)
A 80
)
B 40
)
C 32
)
D 72
)
Ans: B
Question 15
Choose the correct answer.
Tanuj writes the code for a function that takes as input n and
calculates the sum of first n natural numbers
Function sum( n )
{
if(??)
return 1
else
return (n + sum(n-1))
end
}
Fill in ?? in the code:-
A N equal 1
)
B N equal 2
)
C N>=1
)
D N>1
)
Question 16
Choose the correct answer.
Shrishti writes the code for a function that computes the factorial
of the inputted number n.
function factorial(n)
{
if(n equals 1)
return 1
else
— MISSING STATEMENT —
end
}
Fill in the missing statement:-
A return factorial(n-1)
)
B return n*factorial(n)
)
C return n*(n-1)
)
D return n*factorial(n-1)
)
Fill in the missing statement:-
A return factorial(n-1)
)
B return n*factorial(n)
)
C return n*(n-1)
)
D return n*factorial(n-1)
)
Ans: D
Question 17
Choose the correct answer. Saumya writes a code which has a
function which calls itself. Which programming concept is Saumya
using?
A This is bad programming practice and should not be done
)
B Recursion
)
C Decision Making
)
D Overloading
)
Question 17
Choose the correct answer. Saumya writes a code which has a
function which calls itself. Which programming concept is Saumya
using?
A This is bad programming practice and should not be done
)
B Recursion
)
C Decision Making
)
D Overloading
)
Ans: B
Question 18
What type of value does sizeof() return?
A) char
B) short
C) Unsigned int
D) long
Question 18
What type of value does sizeof() return?
A) char
B) short
C) Unsigned int
D) long
Ans: C
Question 19
What will be output of the following program
#include<stdio.h>
int main()
{
float a[]={12.4,2.3,4.5,6.7};
printf("%d,%d",sizeof(a),sizeof(a[0]));
return 0;
}
A 16bytes, 4bytes
)
B 14bytes, 4bytes
)
C 8bytes, 4bytes
)
D None of these
)
A 16bytes, 4bytes
)
B 14bytes, 4bytes
)
C 8bytes, 4bytes
)
D None of these
)
Ans: A
Question 20
Choose the correct answer.
function g(int n)
{
if (n > 0) return 1;
else return -1;
}
A Always -1
)
B 1 if a>b, -1 if a<b, 0 otherwise
)
D 0 if a equals b, -1 otherwise
)
If f(a,b) is called, what is returned?
A Always -1
)
B 1 if a>b, -1 if a<b, 0 otherwise
)
D 0 if a equals b, -1 otherwise
)
Ans: D
Question 21
Choose the correct answer.
Afzal writes a piece of code, where a set of three lines occur around
10 times in different parts of the program. What programming
concept can he use to shorten his program code length?
A Use for loops
)
B Use functions
)
C Use arrays
)
D Use classes
)
A Use for loops
)
B Use functions
)
C Use arrays
)
D Use classes
)
Ans: B
Question 22
Talika wants to implement heterogeneous linked list for her project.
Which of the following will help her do the same?
A Void Pointer
)
B NULL Pointer
)
C Wild Pointer
)
D Heterogeneous lists follows the same procedure as the
) homogeneous.
Question 22
Talika wants to implement heterogeneous linked list for her project.
Which of the following will help her do the same?
A Void Pointer
)
B NULL Pointer
)
C Wild Pointer
)
D Heterogeneous lists follows the same procedure as the
) homogeneous.
Ans: A
Question 23
Which is correct with respect to size of the datatypes?
A char
)
B double
)
C float
)
D int
)
Question 24
The format identifier ‘%i’ is also used for _____ data type?
A char
)
B double
)
C float
)
D int
)
Ans: D
Question 25
What will be the output?
#include <stdio.h>
int main()
{
int main = 5;
printf("%d", main);
return 0;
}
A compile-time error
)
B run-time error
)
B run-time error
)
Ans: C
Question 26
Which of the following is true for variable names in C?
#include <stdio.h>
void main()
{
int i = 0;
if (i == 0)
{
printf("Hello");
break;
}
}
A Hello is printed infinite times
)
B Hello
)
C Varies
)
B Hello
)
C Varies
)
Ans: D
Question 28
The output of this C code is?
#include <stdio.h>
int main()
{
int i = 0;
do{
i++;
printf("Inside while loop\n");
}while (i < 3);
}
A Inside while loop
) Inside while loop
Inside while loop
B Inside while loop
) Inside while loop
Ans: A
Question 29
The output of this C code is?
#include <stdio.h>
int main()
{
do
printf("Inside while loop ");
while (0);
printf("Outside loop\n");
}
A Inside while loop
)
C Outside loop
)
D Infinite loop
)
Ans: B
Question 30
The output of this C code is?
#include <stdio.h>
void main()
{
double x = 0;
for (x = 0.0; x < 3.0; x++)
printf("Hello");
}
A Run time error
)
Ans: B
Question 31
The output of this C code is?
#include <stdio.h>
void main()
{
int x = 0;
for (x < 3; x++)
printf("Hello");
}
A Compile time error
)
C Nothing
)
D Varies
)
A Compile time error
)
C Nothing
)
D Varies
)
Ans: A
Question 32
What is the problem in the following declarations?
int func(int);
double func(int);
int func(float);
A A function with same name cannot have different signatures
)
Ans: D
Question 33
In 2 Dimensional Array, it is necessary to mention _______
dimension.
A second
)
B first
)
C both
)
D none of these
)
Question 33
In 2 Dimensional Array, it is necessary to mention _______
dimension.
A second
)
B first
)
C both
)
D none of these
)
Ans: A
Question 34
An array can be passed to a function by __________
A Call by reference
)
B call by value
)
C Call by reference by passing base address to a function
)
D Both a and c
)
Question 34
An array can be passed to a function by __________
A Call by reference
)
B call by value
)
C Call by reference by passing base address to a function
)
D Both a and c
)
Ans: A
Question 35
What is the output of this C code?
#include<stdio.h>
int main()
{
int arr[4]={3,4,5,6};
int k[4];
k=arr;
printf("%d\n",k[1]);
}
A Compile Time Error
)
B 4
)
C No output
)
D Program crashes
)
A Compile Time Error
)
B 4
)
C No output
)
D Program crashes
)
Ans: A
Question 36
What will be output of the following program
#include<stdio.h>
int main()
{
int a[5],i=0;
while(i<5)
a[i]=++i;
for(i=0;i<5;i++)
printf("%d,",a[i]);
}
A garbage value,1,2,3,4
)
B 1,2,3,4,5
)
C Error
)
D Program crash
)
A garbage value,1,2,3,4
)
B 1,2,3,4,5
)
C Error
)
D Program crash
)
Ans: A
Question 37
What happen if we assign a value to an array element whose
subscript exceeds the size of array?
A Data type
)
B Dimension
)
C name
)
D Data type and Dimension
)
Question 38
If array is initialized where it is declared, then mentioning
__________ of array is optional.
A Data type
)
B Dimension
)
C name
)
D Data type and Dimension
)
Ans: B
Question 39
Till the array elements are not given any specific value, they are
supposed to
contain all ____________
A Zero
)
B Garbage value
)
C One
)
D Combination of zero and one
)
Question 39
Till the array elements are not given any specific value, they are
supposed to
contain all ____________
A Zero
)
B Garbage value
)
C One
)
D Combination of zero and one
)
Ans: B
Question 40
An array is also known as ___________
A Subscripted variable
)
B Collective array
)
C Ordinary variable
)
D Similar Quantities variable
)
Question 40
An array is also known as ___________
A Subscripted variable
)
B Collective array
)
C Ordinary variable
)
D Similar Quantities variable
)
Ans: A
Question 41
What is the output of this C code?
#include <stdio.h>
void main()
{
int x = 97;
int y = sizeof(x++);
printf("x is %d", x);
}
A x is 97
)
B x is 98
)
C x is 99
)
B x is 98
)
C x is 99
)
Ans: A
Question 42
Which of the following statement is true about C language ?
Ans: C
Question 44
To print a double value which format specifier should be used?
A) %lf
B) %Lf
C) %f
D) %df
Question 44
To print a double value which format specifier should be used?
A) %lf
B) %Lf
C) %f
D) %df
Ans: A
Question 45
Which of the following statement is true about C language ?
Ans: C
Question 48
Which of the following statement is true about static variable?
Ans: D
Question 49
Which of the following statement is true about arrays and pointer?
Ans: B
Question 50
Memory allocation using malloc() is done in?
A) Static area
B) Heap area
C) Both a and b
D) None
Question 50
Memory allocation using malloc() is done in?
A) Static area
B) Heap area
C) Both a and b
D) None
Ans: B
THANK YOU