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

Tcs Questions

The document provides information on 10 multiple choice questions that will be asked in programming, broken down by topic. It lists the topic, approximate number of questions, suggested time to solve, difficulty level and importance for each topic. Topics include data types, functions, recursion/iteration, arrays, trees/graphs and more. The highest difficulty and importance levels are assigned to recursion/iteration, arrays and linked lists.

Uploaded by

sujeeth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views

Tcs Questions

The document provides information on 10 multiple choice questions that will be asked in programming, broken down by topic. It lists the topic, approximate number of questions, suggested time to solve, difficulty level and importance for each topic. Topics include data types, functions, recursion/iteration, arrays, trees/graphs and more. The highest difficulty and importance levels are assigned to recursion/iteration, arrays and linked lists.

Uploaded by

sujeeth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 47

Total programming MCQ’ Questions :10 with question wise

time cutoff

Data Types

 Approx Number of Questions - 0 or 1


 Suggested time to solve - 25 secs
 Difficulty Level - Low
 Importance - Med

Functions

 Approx Number of Questions - 1


 Suggested time to solve - 1 min 20 secs
 Difficulty Level - Med
 Importance - Med

Scope

 Approx Number of Questions - 0 or 1


 Suggested time to solve - 1 min 55 secs
 Difficulty Level - Med
 Importance - Low

Recursion and Iteration

 Approx Number of Questions - 0 or 1


 Suggested time to solve - 1 min 50 secs
 Difficulty Level - High
 Importance - High

Arrays

 Approx Number of Questions - 1


 Suggested time to solve - 1 min 45 secs
 Difficulty Level - High
 Importance - High

Variables & Registers

 Approx Number of Questions - 0 or 1


 Suggested time to solve - 35 secs
 Difficulty Level - Low
 Importance - Low

Command Line

 Approx Number of Questions - 1


 Suggested time to solve - 1 min 15 secs
 Difficulty Level - Med
 Importance - High

Trees & Graphs

 Approx Number of Questions - 2


 Suggested time to solve - 1 min 45 secs
 Difficulty Level - High
 Importance - High

Stacks and Queues

 Approx Number of Questions - 1 or 2


 Suggested time to solve - 1 min 35 secs
 Difficulty Level - Med
 Importance - Med

Linked Lists

 Approx Number of Questions - 1


 Suggested time to solve - 1 min 45 secs
 Difficulty Level - High
 Importance - High

OOPs

 Approx Number of Questions - 1 or 2


 Suggested time to solve - 1 min 35 secs
 Difficulty Level - High
 Importance - High

Topic Data Types

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
pre processor

SkipHide 

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
40

B
30

C
4165

D
4166

SkipHide 

A data type is stored as a 6 bit signed integer. Which of the following cannot be represented
by this data type?

A
-12

B
6

C
18

D
32

SkipHide 

A language has 28 different letters in total. Each word in the language iscomposed of
maximum 7 letters. You want to create a data-type to store a word ofthis 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
35

B
7

C
28

D
196

SkipHide 

A 10-bit unsigned integer has the following range:

A
0 to 1000
B
0 to 1024
C
0 to 1023
D
0 to 1025

Parul takes as input two numbers: a and b. a and b can take integer valuesbetween 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 = 200 b = 10

B
a = 10 b = 200

C
a = 50 b = 100

D
a = 100 b = 50

SkipHide 

Which is used to convert source code to target language

A
Linker

B
Loader

C
Executer

D
Compiler

SkipHide 

Tricha wants to store a list of binary data.Which of following data types should she use?

A
Boolean

B
Integer

C
Character

D
Boolean

SkipHide 

Which of the following options is an exception to being a part of composite data types?

A
Union
B
Structure
C
Arrays
D
Stacks
SkipHide 

Which of the following is not valid variable name declaration?

A
int __v1;

B
int __1v;

C
int __V1;

D
None

Variable names beginning with underscore is not encouraged. Why?

A
It is not standard form
B
To avoid conflicts since assemblers and loaders use such names
C
To avoid conflicts since library routines use such names
D
To avoid conflicts with environment variables of an operating system
 

Which is not a valid C variable name?

A
int number;

B
float rate;

C
int variable_count;

D
int $main;

Which of the following is true for variable names in C?

A
They can contain alphanumeric characters as well as special characters
B
It is not an error to declare a variable to be one of the keywords(like goto, static)
C
Variable names can’t start with a digit
D
Variable can be of any length

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
C
run without any error and prints 5
D
experience infinite looping

Which of the following cannot be a variable name in C?

A
friend

B
true

C
volatile

D
export

The format identifier ‘%i’ is also used for _____ data type?

A
char

B
double

C
float

D
int

Which of the following is a User-defined data type?

A
struct {char name[10], int age};

B
typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;

C
typedef int Boolean;

D
all of the mentioned

What is short int in C programming?

A
Basic datatype of C

B
Qualifier

C
short is the qualifier and int is the basic datatype

D
All of the mentioned

What is the output of this C code? #include  <stdio.h> int main() { signed char chr; chr =
128; printf(“%d\n”, chr); return 0; }

A
128
B
-128
C
Depends on the compiler
D
None of the mentioned

What is the size of an int data type?

A
4 Bytes

B
8 Bytes

C
Depends on the system/compiler

D
Cannot be determined

Which of the datatypes have size that is variable?

A
int

B
struct

C
float

D
double

What is the output of this C code?

#include <stdio.h>

int main()

float x = ‘a’;

printf(“%f”, x);

return 0;

A
97.000000

B
run time error

C
a.0000000

D
a

SkipHide 

Which is correct with respect to size of the datatypes?

A
char > int > float

B
int > char > float

C
char < int < double

D
double > char > int

What is the size of an int data type?

A
4 Bytes

B
8 Bytes

C
Depends on the system/compiler

D
Cannot be determined

SkipHide 

Which of the datatypes have size that is variable?

A
int

B
struct

C
float

D
double

SkipHide 
What is the output of this C code?

#include <stdio.h>

int main()

float x = ‘a’;

printf(“%f”, x);

return 0;
}

A
97.000000

B
run time error

C
a.0000000

D
a

SkipHide 

Variable name resolving (number of significant characters for uniqueness of variable)


depends on

A
Compiler and linker implementations

B
Assemblers and loaders implementations

C
C language

D
None

SkipHide 
Consider on following declaration:
(i)        short i=10;
(ii)       static i=10;
(iii)     unsigned i=10;
(iv)      const i=10;

A
Only (iv) is incorrect
B
Only (ii) and (iv) are incorrect
C
Only (ii),(iii) and (iv) are correct
D
All are correct declaration
SkipHide 

Which of the following is not a valid variable name declaration?

A
float PI = 3.14;

B
#define PI 3.14;

C
double PI = 3.14;

D
int PI = 3.14;

The format identifier  ‘%i’  is also used for _____ data type?

A
char

B
double

C
int

D
float

 
Literal means ?

A
a string.

B
a string constant.
C
a character.

D
an alphabet.

SkipHide 

What will happen if the below program is executed?

#include <stdio.h>
int main() {
int main = 3;
printf(“%d”, main);
return 0;
}

A
It will cause a compile-time error

B
It will cause a run-time error

C
It will run without any error and prints 3

D
It will experience infinite looping

SkipHide 

Functions
What is the difference between a function and a method?

A
Function is a named code unlike method which is a part of an object

B
Function contained in an object is called a method

C
Function cannot change variables outside its scope unlike method

D
There is no difference between the two

SkipHide 

Consider the following code:

function modify(a,b)

Integer c,d=2

c= a*d+ b

return c

}
function calculate()

integer a = 5, b = 20, c

integer d= 10

c = modify(a, b);

c = c+ d

print c

A
80

B
40

C
32

D
72
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

Anu wants to make a function that is not bound to any identifier. Which of the following
functions should she incorporate in her program?

A
Only Private

B
Protected and Private

C
Public and No Modifier

D
Only No Modifier

Which of the following accessibility modes can be the specifier of a top level class’?Top-
level classes can only have public, abstract, and final modifiers, and it is also possible to not
define any class modifiers at all. This is called default/package accessibility. Besides that,
private, protected, and static modifiers cannot be used when declaring top-level classes.

Private, Protected, Public, No Modifier

A
Only Private

B
Protected and Private

C
Public and No Modifier

D
Only No Modifier

Choose the correct answer. A pseudo-code which is similar to that of C++ and self-
explanatory An accessible member function or data member for an object are accessed by
the statement objectname.functionname or objectname. data member name respectively.

class brush
{

Private:
integer size, colorcode
function getdata( ) {--}//Statement 1
public:
integer name // Statement 2
function putdata(){...}
}

function main
{

brush b1, b2
print bl.name //Statement 3
b2.getdata() //Statement 4
}

Deleting which line will correct the error in the code?

A
Statement 1

B
Statement 2

C
Statement 3

D
Statement 4

function MyDisplay(string MyStr) //statement 1


{
print "Hello !"
print MyStr
return 1 // statement 2
}
function main() //statement 3
{
string str= "Mickey"
MyDisplay(str) // statement 4
}
Which statement will generate an error.

A
Statement 1

B
Statement 2

C
Statement 3

D
Statement 4

SkipHide 

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
Anonymous Function

B
Friend Function

C
Null Function

D
Global Function

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)

What is the output of this C code?

#include <stdio.h>
int main() {
int y = 10000;
int y = 34;
printf(“Hello World! %d\n”,y);
return 0;
}

A
Compile time error

B
Hello World! 34

C
Hello World! 1000

D
Hello World! followed by a junk value

SkipHide 
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
function

B
Null pointer

C
Wild pointer

D
Heterogeneous list follows the same procedure as the homogeneous list. Hence no different
pointer is required.

Talika wants to implement heterogeneous linked list for her project. Which of the following
will help her do the same.

A
This is bad programming practice and should not be done.

B
void pointer

C
Decision Making

D
Overloading
Choose the correct answer
Saumya writes a code which has a function which calls itself. Which programming concept
is Saumya using?

A
Recursion

B
Overloading

C
Decision Making

D
This is Bad programming And should not be done O.OO %

Consider the following function

function calculate( n )
{
if(n equals 5)
return 5
else
return (n + calculate(n-5))
end
}

Shishir calls the function by the statement, calculate(20). What value will the function
return?

A
20

B
30

C
40

D
50

Choose the correct answer


function g(int n)
{
if (n > 0) return 1;
else return -1;
}

function f(int a, int b)


{
if (a > b) return g(b-a);
if (a < b) return g(a-b);
return 0;
}

If f(a,b) is called, what is returned?

A
Always -1

B
0 if a equals b, -1 otherwise

C
1 if a > b, -1 if a < b, 0 otherwise

D
-1 if a > b, 1 if a < b, 0 otherwise

In C, if you pass an array as an argument to a function, what actually gets passed?

A
Value of elements in array

B
First element of the array

C
Base address of the array

D
Address of the last element of array

What does the following declaration mean?

int (*ptr)[10];

A
ptr is array of pointers to 10 integers

B
ptr is a pointer to an array of 10 integers

C
ptr is an array of 10 integers

D
ptr is an pointer to array

What will happen if in a C program you assign a value to an array element whose subscript
exceeds the size of array?

A
The element will be set to 0.

B
The compiler would report an error.

C
The program may crash if some important data gets overwritten.

D
The array size would appropriately grow

Which of the fplowing statements should be used to obtain a remainder after dividing 3.14
by 2.1?

A
rem = 3.14 % 2.1;

B
rem = modf(3.14, 2.1);

C
rem = fmod(3.14, 2.1);

D
Remainder cannot be obtain in floating point division.

SkipHide 
 

What will be the output of the program?

#include<stdio.h>
int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
}

A
2, 1, 15

B
1, 2, 5

C
3, 2, 15

D
2, 3, 20

SkipHide 

What is the output of this C code? #include <stdio.h> void main() { m(); void m()
{ printf(“SimpleWay2Code”); } }

A
SimpleWay2Code

B
Compile time error

C
Nothing

D
Varies

SkipHide 

What is the output of this C code? #include <stdio.h> void main() { static int x = 3; x++; if
(x <= 5) { printf(“hello”); main(); } }

A
Run time error

B
hello
C
Infinite hello

D
hello hello

The value obtained in the function is given back to main by using ________ keyword?

A
return

B
static

C
new

D
volatile

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
B
A function with same name cannot have different return types

C
A function with same name cannot have different number of parameters

D
All of the mentioned

What is the return-type of the function sqrt()

A
int

B
float

C
double

D
depends on the data type of the parameter

What is the output of this code having void return-type function? #include <stdio.h>
void foo() { return 1; } void main() { int x = 0; x = foo(); printf(“%d”, x); }
A
1

B
Runtime error

C
Compile time error

The output of the code below is #include <stdio.h> void main() { int k = m(); printf(“%d”,
k); } void m() { printf(“hello”); }

A
hello 5

B
Error

C
Nothing

D
Garbage value

The output of the code below is #include <stdio.h> int *m() { int *p = 5; return p; } void
main() { int *k = m(); printf(“%d”, k); }
A
5

B
Junk value

C
Error

SkipHide 

What will be the output of the program? #include<stdio.h> int main() { int i=1; if(!i)
printf(“SimpleWay2Code,”); else { i=0; printf(“C-Program”); main(); } return 0; }

A
prints “SimpleWay2Code, C-Program” infinitely

B
prints “C-Program” infinetly

C
prints “C-Program, SimpleWay2Code” infinitely

D
Error: main() should not inside else statement

SkipHide 
How many times the program will print “SimpleWay2Code” ? #include<stdio.h> int
main() { printf(“SimpleWay2Code”); main(); return 0; }
A
Infinite times

B
32767 times

C
65535 times

D
Till stack overflows

Topic Time complexity

What is the time, space complexity of following code:


int a = 0, b = 0;

for (i = 0; i < N; i++) {

    a = a + rand();

for (j = 0; j < M; j++) {

    b = b + rand();

A
O(N * M) time, O(1) space
B
O(N + M) time, O(N + M) space

C
O(N + M) time, O(1) space

D
O(N * M) time, O(N + M) space

What is the time complexity of the following code:

int a = 0, i = N;

while (i > 0) {

    a += i;

    i /= 2;

A
O(N)

B
O(Sqrt(N))

C
O(N / 2)

D
What does it mean when we say that an algorithm X is asymptotically more efficient than Y?

A
X will always be a better choice for small inputs

B
X will always be a better choice for large inputs

C
Y will always be a better choice for small inputs

D
X will always be a better choice for all inputs

What is the time complexity of the following code:


int i, j, k = 0;

for (i = n / 2; i <= n; i++) {

    for (j = 2; j <= n; j = j * 2) {

        k = k + n / 2;

    }

A
O(n)
B
O(nLogn)

C
O(n^2)

D
O(n^2Logn)

What is the time complexity of the following code:


int a = 0;

for (i = 0; i < N; i++) {

    for (j = N; j > i; j--) {

        a = a + i + j;

    }

A
O(N)

B
O(N*log(N))

C
O(N*log(N))

D
O(N*N)

Which of the following case does not exist in complexity theory?

A
Best case

B
Worst case

C
Average case

D
Null case

The worst-case occurs in quick sort when

A
Pivot is the median of the array

B
Pivot is the smallest element

C
Pivot is the middle element
D
None of the mentioned

The worst-case complexity of quicksort is

A
O(n)

B
O(log n)

C
O(n2)

D
O(n log n)

The complexity of merge sort algorithm is

A
O(n)

B
O(log n)

C
O(n2)

D
O(n log n)

The worst-case complexity for insertion sort is

A
O(n)

B
O(log n)

C
O(n2)

D
O(n log n)

SkipHide 

You might also like