SlideShare a Scribd company logo
1
End Semester Examination
Introduction to Computing (CS 101)
IIT Guwahati
April 29, 2014
Duration: 3 Hours
Instructions:
(1) Encircle the answer (A/B/C/D/E) in the space provided in the answer script.
(2) Each question has exactly one correct answer.
(3) There are a total of 50 questions. Each question carries two marks.
(4) Negative Marking: Each wrong answer will be penalised by 1
2
negative marks.
(5) Please write your name and roll number on both the question paper and the answer script.
(6) Possession of either a mobile phone or a calculator is strictly prohibited during the exam.
(7) No doubts will be entertained during the exam.
(8) There are 6 pages of questions and 2 pages for rough work in the question paper. Please contact the invigilator, if otherwise.
Name: Roll No:
1. The conversion of a program from some high-level
programming language to machine language (object
code) is done by a .
(A) Compiler
(B) Loader
(C) Linker
(D) All of the above
(E) None of the above
2. Which of the following is not a storage device?
(A) Hard Disk
(B) CD ROM
(C) Keyboard
(D) Floppy Disk
(E) None of the above
3. In C programming, the name of an array indicates
the .
(A) Address of the first element of the array
(B) First element of the array
(C) Number of elements in the array
(D) Data type of the elements stored in the array
(E) None of the above
4. Which of these data types is used by an operating
system to manage the recursion in C programming?
(A) Stack
(B) Queue
(C) Linked List
(D) Array
(E) None of the above
5. Let A be an array containing n distinct integers. If
i < j and A[i] > A[j], then the pair (i, j) is called an
inversion of A. Which array containing the elements
{1, 2, . . . , n} has the most and the least number of
inversions, respectively?
(A) Most: {1, 2, . . . , n}, Least: {1, 2, . . . , n}
(B) Most: {1, 2, . . . , n}, Least: {n, n − 1, . . . , 1}
(C) Most: {n, n − 1, . . . , 1}, Least: {1, 2, . . . , n}
(D) Most: {n, n − 1, . . . , 1}, Least: {n, n − 1, . . . , 1}
(E) None of the above
6. Identify the equivalent postfix representation for the
following infix expression: A + B ∗ C + D
(A) AB + CD + ∗
(B) ABCD + +∗
(C) ABCD + ∗+
(D) ABC ∗ +D+
(E) None of the above
7. Evaluate the postfix expression: 2 3 ∗ 4 5 ∗ +
(A) 36
(B) 50
(C) 70
(D) 120
(E) None of the above
8. Identify the correct statement.
(A) Matrix multiplication of two n×n matrices can
be done in O(n3
) time.
(B) Matrix multiplication of two n×n matrices can
be done in O(n2
) time.
(C) Matrix multiplication of two n×n matrices can
be done in O(n) time.
(D) All of the above
(E) None of the above
2
9. Which of the following sorting algorithms has the
fastest possible best-case time complexity for n ele-
ments?
(A) Selection sort (without using an auxiliary array)
(B) Selection sort (using an auxiliary array)
(C) Insertion sort
(D) Both A and B
(E) All of the above
10. The worst-case time complexity for searching an el-
ement from a set of n sorted elements using binary
search algorithm is
(A) O(log n)
(B) O((log n)
2
)
(C) O(log log n)
(D) O(1)
(E) None of the above
11. Consider the sorted array declared by “int A[9]={1,
2, 3, 4, 5, 6, 7, 8, 9};”. What is the number of
comparisons (between elements) required to find the
element 7 using binary search? Note that mid =
⌊low+high
2 ⌋.
(A) 2
(B) 3
(C) 4
(D) 5
(E) 9
12. Consider the array declared by “int A[9]={9, 8, 7, 6,
5, 4, 3, 2, 1};”. What is the number of comparisons
(between elements) required to find the element 7
using linear search, starting from the beginning of
the array?
(A) 2
(B) 3
(C) 4
(D) 5
(E) 9
13. Suppose we have some distinct numbers between 1
and 1000 stored in a sorted array, and we want to
search the number 500 using binary search. Which
of the following is a valid binary search sequence?
(A) 100, 400, 300, 600, 500
(B) 400, 800, 700, 600, 500
(C) 200, 100, 600, 800, 500
(D) 300, 900, 700, 800, 500
(E) None of the above
14. Assume A to be an array of integers (e.g., “int A[5]
= {1, 2, 3, 4, 5};”). Indicating equivalence by ‘≡’,
which of the following statements is incorrect?
(A) A[i] ≡ ∗(A + i)
(B) A ≡ &A[0]
(C) &A[i] ≡ A + i
(D) (i − j) ≡ (&A[i] − &A[j])
(E) None of the above
15. Identify the data structure (among the following
ones) that consumes the highest amount of space
to store a set of n integers. Assume that n is large.
[Note: Consider the most space-efficient implemen-
tation of each data structure.]
(A) One-dimensional array
(B) Singly linked-list
(C) Doubly linked-list
(D) Stack
(E) Queue
16. What will be the output for the code segment below?
#include <stdio.h>
int main ()
{
int a[] = {10, 20, 30, 40, 50};
int i;
for(i=0; i<5; ++i)
printf("%d,", *(a+i));
printf("n");
return 0;
}
(A) 10, 10, 10, 10, 10,
(B) 10, 20, 30, 40,
(C) 10, 20, 30, 40, 50,
(D) Garbage values
(E) None of the above
17. What will be the output for the code segment below?
#include <stdio.h>
int main ()
{
int a[3][3] = {1,2,3,4,5,6,7,8,9};
int *ptr [3] = {a[0],a[1],a[2]};
int i;
for(i=0; i<3; ++i)
printf("%d,", *ptr[i]);
return 0;
}
(A) 1, 1, 1,
(B) 1, 2, 3,
(C) 1, 4, 7,
(D) Garbage values
(E) None of the above
3
18. What will be the output for the code segment below?
#include <stdio.h>
typedef struct {
int i;
float f;
} values;
int main ()
{
values var ={555 , 67.05501};
printf("%d ,%.2f", var.i, var.f);
return 0;
}
(A) 555, 67
(B) 555, 67.06
(C) 555, 67.05
(D) 555, 67.05501
(E) None of the above
19. The output of the following code segment is
0x7fff70b4e3b0, . Choose the correct option
for filling up the blank.
#include <stdio.h>
void main ()
{
int a[5] = {10, 20, 30, 40, 50};
printf("%p,%pn", a, &a);
}
(A) 0x7fff70b4e3b0
(B) 10
(C) Address of the location containing
0x7fff70b4e3b0
(D) Compile time error
(E) None of the above
20. Given an array A = {10, 30, 40, 50, 20}, calculate the
number of swap operations required to sort the ele-
ments in an increasing order using Bubble sort.
(A) 1
(B) 2
(C) 3
(D) 4
(E) 5
21. Given an array A = {10, 20, 30, 40, 50}, calculate the
number of comparisons (between elements) required
to sort the elements in an increasing order using the
most efficient implementation (one that requires the
minimum number of comparisons in the best-case)
of Bubble sort.
(A) 0
(B) 4
(C) 5
(D) 9
(E) 10
22. The following program will create a file file.txt.
What will be the content of the file.txt after the
execution of the program?
#include <stdio.h>
int main ()
{
FILE *fp;
fp = fopen("file.txt","w+");
fputs("abcdef", fp);
fseek(fp , -2, 1);
fputs("pqrst", fp);
fclose(fp);
return (0);
}
(A) abcdefpqrst
(B) abcdepqrst
(C) abcdefqrst
(D) abcdpqrst
(E) None of the above
23. What will be the output for the code segment below?
#include <stdio.h>
#include <string.h>
int main ()
{
char str1 [15];
char str2 [15];
int ret;
strcpy(str1 , "aAbBcC");
strcpy(str2 , "aABbcC");
ret = strcmp(str1 , str2 );
if(ret > 0)
printf("str2 <str1");
else if(ret < 0)
printf("str1 <str2");
else
printf("str1=str2");
return (0);
}
(A) str2<str1
(B) str1<str2
(C) str1=str2
(D) Compile time error
(E) None of the above
24. Given an array A = {40, 30, 10, 50, 20}, calculate the
number of swap operations required to sort the el-
ements in an increasing order using Selection sort
that requires O(1) (constant) worst-case space com-
plexity, i.e., does not use an auxiliary array.
(A) 1
(B) 2
(C) 3
(D) 4
(E) 5
4
25. Given an array A = {10, 20, 30, 40, 50}, calculate the
number of comparisons (between elements) required
to sort the elements in an increasing order using in-
sertion sort.
(A) 0
(B) 4
(C) 5
(D) 9
(E) 10
26. Consider an array A = {329, 457, 657, 839, 436, 720,
355}, which we are trying to sort using radix sort
starting from the least significant digit, using 3 it-
erations. What would be the order of the elements
after the second iteration?
(A) {720, 355, 436, 457, 657, 329, 839}
(B) {720, 329, 436, 839, 355, 457, 657}
(C) {720, 329, 436, 839, 457, 355, 657}
(D) {720, 329, 839, 436, 457, 355, 657}
(E) None of the above
27. Which of the following sorting algorithms is stable?
(A) Insertion sort
(B) Bubble sort
(C) Counting Sort
(D) All of the above
(E) None of the above.
28. Consider an empty stack S in which the follow-
ing sequence of operations are performed: Push(4),
Push(6), Pop(), Push(8), Push(9), Push(1),
Push(2), Pop().
Which of the elements are present in the stack after
the above operations?
(A) 4, 6, 8, 9
(B) 4, 8, 9, 1
(C) 8, 9, 1, 2
(D) 6, 8, 9, 1
(E) None of the above
29. Consider an empty queue Q in which the following
sequence of operations are performed: Enqueue(4),
Enqueue(6), Dequeue(), Enqueue(8), Enqueue(9),
Enqueue(1), Enqueue(2), Dequeue().
Which of the elements are present in the queue after
the above operations?
(A) 4, 6, 8, 9
(B) 4, 8, 9, 1
(C) 8, 9, 1, 2
(D) 6, 8, 9, 1
(E) None of the above
30. What will be the output for the code segment below?
#include <stdio.h>
void swap1(int a, int b)
{
int temp;
temp = a;
a = b;
b = temp;
}
void swap2(int *a, int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}
void main ()
{
int i=10, j=20, k=30, l=40;
swap1(i, j);
swap2 (&k, &l);
printf("%d,%d,%d,%dn",i,j,k,l);
}
(A) 10, 20, 30, 40
(B) 20, 10, 30, 40
(C) 10, 20, 40, 30
(D) 20, 10, 40, 30
(E) None of the above
31. Consider a singly linked list L in which every node
(structure) consists of two members. The first mem-
ber is an integer data d. Identify the correct data
type for the second member.
(A) Integer
(B) Pointer to an integer
(C) Pointer to a pointer to an integer
(D) Pointer to a node
(E) None of the above
32. Identify the number of bytes required to store the
string “This is an easy question” in a C program.
(A) 20
(B) 21
(C) 24
(D) 25
(E) None of the above
33. Given an integer array declared by “int A[3][5];”,
which of the following statements does not repre-
sent the element A[2][3]?
(A) (∗(A[2] + 3))
(B) (∗(A + 2))[3]
(C) (∗((∗(A + 2)) + 3))
(D) (A[2] + 3)
(E) None of the above
5
34. Given an integer array declared by
“int A[ ] = {2, 4, 6, 8, 3};”, what is the value of
A[A[1]]?
(A) 2
(B) 4
(C) 6
(D) 8
(E) 3
35. Identify the 2’s complement representation of the
negative integer −127, using 8 bits.
(A) 10000001
(B) 11111111
(C) 01111111
(D) 10000000
(E) None of the above
36. The number of 1’s in the binary representation of
the integer 13 ∗ 163
+ 11 ∗ 162
+ 9 ∗ 16 + 3 is:
(A) 7
(B) 8
(C) 9
(D) 10
(E) None of the above
37. Given an integer array declared by “int A[10];”, what
is the value of ((&A[2])−(&A[6]))? Assume that an
integer takes 4 bytes.
(A) −4
(B) −16
(C) 4
(D) 16
(E) None of the above
38. If two pointers p1 and p2 are declared by “int *p1,
*p2;”, identify the invalid statements.
(A) p1 = p1 + 2;
(B) p1 = p1 − 2;
(C) p1 = p1 ∗ 2;
(D) int i = p1 − p2;
(E) None of the above
39. Consider a singly linked-list with a head and a tail
pointer (i.e., pointers to the first and last node in the
list). Given this representation, which of the follow-
ing operations can not be implemented in constant
time (i.e., O(1) time)?
(A) Insert an item at the front of the list
(B) Insert an item at the rear of the list
(C) Delete the front item from the list
(D) Delete the rear item from the list
(E) None of the above
40. Consider the following code segment. Identify the
invalid statement to assign a value to member1.
#include <stdio.h>
struct test{
int member1;
} var;
void main ()
{
struct test *ptr=&var;
/* identify the invalid statement.*/
}
(A) (*ptr).member1=5;
(B) *ptr.member1=5;
(C) (ptr)->member1=5;
(D) ptr->member1=5;
(E) None of the above
41. In C programming, the return type of a malloc()
function is
(A) An integer
(B) A void pointer
(C) A pointer to an integer
(D) Pointer to an array
(E) None of the above
42. What is the equivalent pointer expression for refer-
ring the array element A[i][j][k][l] in an integer array
A[10][10][10][10]?
(A) ((((A+i)+j)+k)+l)
(B) (*(*(*(*(A+i)+j)+k)+l))
(C) (((A+i)+j)+k+l)
(D) ((A+i)+j+k+l)
(E) None of the above
43. In C programming, the size of a union is determined
by the size of the .
(A) First member in the union
(B) Last member in the union
(C) Maximum-sized member in the union
(D) Sum of the sizes of all members
(E) None of the above
44. The C syntax for command-line argument is “int
main(int argc, char *argv[ ])”. What is indicated by
argv[0] in command-line arguments?
(A) The name by which the program is invoked
(B) The name of the files which are passed to the
program
(C) Count of the arguments in argv[ ] vector
(D) Both A and B
(E) None of the above
6
45. In C programming, the size of a structure is deter-
mined by the size of the , excluding the slack
bytes.
(A) First member in the structure
(B) Last member in the structure
(C) Maximum-sized member in the structure
(D) Sum of the sizes of all members
(E) None of the above
46. The deletion of a node can always be done in con-
stant (i.e., O(1)) time from a linked list with n nodes
if .
(A) The linked list is singly and the element stored
in the node to be deleted is given
(B) The linked list is singly and the pointer to the
node to be deleted is given
(C) The linked list is doubly and the element stored
in the node to be deleted is given
(D) The linked list is doubly and the pointer to the
node to be deleted is given
(E) None of the above
47. In C programming, identify the valid declaration of
a three-dimensional array.
(A) int A[ ][2][2]={2,2,2,2};
(B) int A[ ][ ][2]={2,2,2,2};
(C) int A[2][2][ ]={2,2,2,2};
(D) Both A and B
(E) Both A and C
48. Which of the following code segments is invalid?
(A) int A[20]; printf(“%p”, A+1);
(B) int A[20]; printf(“%p”, (&A)+1);
(C) int A[20]; printf(“%p”, (&(&A)+1));
(D) Both B and C
(E) None of the above
49. Consider the C code below. How many ‘*’ will be
printed by the following program?
#include <stdio.h>
void quiz(int i)
{
if (i > 1)
{
quiz(i / 2);
quiz(i / 2);
}
printf("*");
}
void main ()
{
quiz (5);
}
(A) 3
(B) 5
(C) 7
(D) 9
(E) None of the above
50. Consider the C code below. How many ‘*’ will be
printed by the following program?
#include <stdio.h>
void quiz(int i)
{
if (i > 1)
{
quiz(i % 2);
quiz(i / 2);
}
printf("*");
}
void main ()
{
quiz (6);
}
(A) 3
(B) 4
(C) 6
(D) 7
(E) None of the above

More Related Content

What's hot

18. Java associative arrays
18. Java associative arrays18. Java associative arrays
18. Java associative arrays
Intro C# Book
 
Gate-Cs 2009
Gate-Cs 2009Gate-Cs 2009
Gate-Cs 2009
Ravi Rajput
 
19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity
Intro C# Book
 
Lec4
Lec4Lec4
Finding root of equation (numarical method)
Finding root of equation (numarical method)Finding root of equation (numarical method)
Finding root of equation (numarical method)
Rajan Thakkar
 
M|18 User Defined Functions
M|18 User Defined FunctionsM|18 User Defined Functions
M|18 User Defined Functions
MariaDB plc
 
11 1. multi-dimensional array eng
11 1. multi-dimensional array eng11 1. multi-dimensional array eng
11 1. multi-dimensional array eng웅식 전
 
Funções 4
Funções 4Funções 4
Funções 4
KalculosOnline
 
Psychtoolbox (PTB) practical course by Volodymyr B. Bogdanov, Kyiv 2017, Day 1
Psychtoolbox (PTB) practical course  by Volodymyr B. Bogdanov, Kyiv 2017, Day 1Psychtoolbox (PTB) practical course  by Volodymyr B. Bogdanov, Kyiv 2017, Day 1
Psychtoolbox (PTB) practical course by Volodymyr B. Bogdanov, Kyiv 2017, Day 1
Volodymyr Bogdanov
 
Numpy Talk at SIAM
Numpy Talk at SIAMNumpy Talk at SIAM
Numpy Talk at SIAM
Enthought, Inc.
 
07. Arrays
07. Arrays07. Arrays
07. Arrays
Intro C# Book
 
Data Structure Project File
Data Structure Project FileData Structure Project File
Data Structure Project File
Deyvessh kumar
 
16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues
Intro C# Book
 
Lec3
Lec3Lec3
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
Aroosa Rajput
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpy
Faraz Ahmed
 

What's hot (18)

18. Java associative arrays
18. Java associative arrays18. Java associative arrays
18. Java associative arrays
 
Gate-Cs 2009
Gate-Cs 2009Gate-Cs 2009
Gate-Cs 2009
 
19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity
 
Lec4
Lec4Lec4
Lec4
 
Finding root of equation (numarical method)
Finding root of equation (numarical method)Finding root of equation (numarical method)
Finding root of equation (numarical method)
 
M|18 User Defined Functions
M|18 User Defined FunctionsM|18 User Defined Functions
M|18 User Defined Functions
 
Chapter2
Chapter2Chapter2
Chapter2
 
11 1. multi-dimensional array eng
11 1. multi-dimensional array eng11 1. multi-dimensional array eng
11 1. multi-dimensional array eng
 
Funções 4
Funções 4Funções 4
Funções 4
 
Psychtoolbox (PTB) practical course by Volodymyr B. Bogdanov, Kyiv 2017, Day 1
Psychtoolbox (PTB) practical course  by Volodymyr B. Bogdanov, Kyiv 2017, Day 1Psychtoolbox (PTB) practical course  by Volodymyr B. Bogdanov, Kyiv 2017, Day 1
Psychtoolbox (PTB) practical course by Volodymyr B. Bogdanov, Kyiv 2017, Day 1
 
Numpy Talk at SIAM
Numpy Talk at SIAMNumpy Talk at SIAM
Numpy Talk at SIAM
 
07. Arrays
07. Arrays07. Arrays
07. Arrays
 
Arrays
ArraysArrays
Arrays
 
Data Structure Project File
Data Structure Project FileData Structure Project File
Data Structure Project File
 
16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues
 
Lec3
Lec3Lec3
Lec3
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpy
 

Similar to Cs101 endsem 2014

Gate-Cs 1999
Gate-Cs 1999Gate-Cs 1999
Gate-Cs 1999
Ravi Rajput
 
Gate-Cs 2006
Gate-Cs 2006Gate-Cs 2006
Gate-Cs 2006
Ravi Rajput
 
Ee693 sept2014midsem
Ee693 sept2014midsemEe693 sept2014midsem
Ee693 sept2014midsem
Gopi Saiteja
 
Computer science ms
Computer science msComputer science ms
Computer science ms
B Bhuvanesh
 
Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007 Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007
Rohit Garg
 
Gate-Cs 1996
Gate-Cs 1996Gate-Cs 1996
Gate-Cs 1996
Ravi Rajput
 
Ee693 questionshomework
Ee693 questionshomeworkEe693 questionshomework
Ee693 questionshomework
Gopi Saiteja
 
Adobe
AdobeAdobe
09 a1ec01 c programming and data structures
09 a1ec01 c programming and data structures09 a1ec01 c programming and data structures
09 a1ec01 c programming and data structuresjntuworld
 
MATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdfMATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdf
ahmed8651
 
Gate Previous Years Papers
Gate Previous Years PapersGate Previous Years Papers
Gate Previous Years Papers
Rahul Jain
 
Gate-Cs 1998
Gate-Cs 1998Gate-Cs 1998
Gate-Cs 1998
Ravi Rajput
 
Technical aptitude test 2 CSE
Technical aptitude test 2 CSETechnical aptitude test 2 CSE
Technical aptitude test 2 CSE
Sujata Regoti
 
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQs
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQsStd 12 Computer Chapter 9 Working with Array and String in Java important MCQs
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQs
Nuzhat Memon
 
(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2Pamidimukkala Sivani
 
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomesh
praveensomesh
 
Redo midterm
Redo midtermRedo midterm
Redo midterm
IIUM
 

Similar to Cs101 endsem 2014 (20)

Gate-Cs 1999
Gate-Cs 1999Gate-Cs 1999
Gate-Cs 1999
 
Gate-Cs 2006
Gate-Cs 2006Gate-Cs 2006
Gate-Cs 2006
 
Ee693 sept2014midsem
Ee693 sept2014midsemEe693 sept2014midsem
Ee693 sept2014midsem
 
Computer science ms
Computer science msComputer science ms
Computer science ms
 
Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007 Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007
 
Gate-Cs 1996
Gate-Cs 1996Gate-Cs 1996
Gate-Cs 1996
 
Ee693 questionshomework
Ee693 questionshomeworkEe693 questionshomework
Ee693 questionshomework
 
Adobe
AdobeAdobe
Adobe
 
09 a1ec01 c programming and data structures
09 a1ec01 c programming and data structures09 a1ec01 c programming and data structures
09 a1ec01 c programming and data structures
 
MATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdfMATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdf
 
Gate Previous Years Papers
Gate Previous Years PapersGate Previous Years Papers
Gate Previous Years Papers
 
Gate-Cs 1998
Gate-Cs 1998Gate-Cs 1998
Gate-Cs 1998
 
Technical aptitude test 2 CSE
Technical aptitude test 2 CSETechnical aptitude test 2 CSE
Technical aptitude test 2 CSE
 
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQs
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQsStd 12 Computer Chapter 9 Working with Array and String in Java important MCQs
Std 12 Computer Chapter 9 Working with Array and String in Java important MCQs
 
Revision1schema C programming
Revision1schema C programmingRevision1schema C programming
Revision1schema C programming
 
Doc 20180130-wa0006
Doc 20180130-wa0006Doc 20180130-wa0006
Doc 20180130-wa0006
 
(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2
 
Revision1 C programming
Revision1 C programmingRevision1 C programming
Revision1 C programming
 
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomesh
 
Redo midterm
Redo midtermRedo midterm
Redo midterm
 

Recently uploaded

Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
MuhammadTufail242431
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 

Recently uploaded (20)

Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 

Cs101 endsem 2014

  • 1. 1 End Semester Examination Introduction to Computing (CS 101) IIT Guwahati April 29, 2014 Duration: 3 Hours Instructions: (1) Encircle the answer (A/B/C/D/E) in the space provided in the answer script. (2) Each question has exactly one correct answer. (3) There are a total of 50 questions. Each question carries two marks. (4) Negative Marking: Each wrong answer will be penalised by 1 2 negative marks. (5) Please write your name and roll number on both the question paper and the answer script. (6) Possession of either a mobile phone or a calculator is strictly prohibited during the exam. (7) No doubts will be entertained during the exam. (8) There are 6 pages of questions and 2 pages for rough work in the question paper. Please contact the invigilator, if otherwise. Name: Roll No: 1. The conversion of a program from some high-level programming language to machine language (object code) is done by a . (A) Compiler (B) Loader (C) Linker (D) All of the above (E) None of the above 2. Which of the following is not a storage device? (A) Hard Disk (B) CD ROM (C) Keyboard (D) Floppy Disk (E) None of the above 3. In C programming, the name of an array indicates the . (A) Address of the first element of the array (B) First element of the array (C) Number of elements in the array (D) Data type of the elements stored in the array (E) None of the above 4. Which of these data types is used by an operating system to manage the recursion in C programming? (A) Stack (B) Queue (C) Linked List (D) Array (E) None of the above 5. Let A be an array containing n distinct integers. If i < j and A[i] > A[j], then the pair (i, j) is called an inversion of A. Which array containing the elements {1, 2, . . . , n} has the most and the least number of inversions, respectively? (A) Most: {1, 2, . . . , n}, Least: {1, 2, . . . , n} (B) Most: {1, 2, . . . , n}, Least: {n, n − 1, . . . , 1} (C) Most: {n, n − 1, . . . , 1}, Least: {1, 2, . . . , n} (D) Most: {n, n − 1, . . . , 1}, Least: {n, n − 1, . . . , 1} (E) None of the above 6. Identify the equivalent postfix representation for the following infix expression: A + B ∗ C + D (A) AB + CD + ∗ (B) ABCD + +∗ (C) ABCD + ∗+ (D) ABC ∗ +D+ (E) None of the above 7. Evaluate the postfix expression: 2 3 ∗ 4 5 ∗ + (A) 36 (B) 50 (C) 70 (D) 120 (E) None of the above 8. Identify the correct statement. (A) Matrix multiplication of two n×n matrices can be done in O(n3 ) time. (B) Matrix multiplication of two n×n matrices can be done in O(n2 ) time. (C) Matrix multiplication of two n×n matrices can be done in O(n) time. (D) All of the above (E) None of the above
  • 2. 2 9. Which of the following sorting algorithms has the fastest possible best-case time complexity for n ele- ments? (A) Selection sort (without using an auxiliary array) (B) Selection sort (using an auxiliary array) (C) Insertion sort (D) Both A and B (E) All of the above 10. The worst-case time complexity for searching an el- ement from a set of n sorted elements using binary search algorithm is (A) O(log n) (B) O((log n) 2 ) (C) O(log log n) (D) O(1) (E) None of the above 11. Consider the sorted array declared by “int A[9]={1, 2, 3, 4, 5, 6, 7, 8, 9};”. What is the number of comparisons (between elements) required to find the element 7 using binary search? Note that mid = ⌊low+high 2 ⌋. (A) 2 (B) 3 (C) 4 (D) 5 (E) 9 12. Consider the array declared by “int A[9]={9, 8, 7, 6, 5, 4, 3, 2, 1};”. What is the number of comparisons (between elements) required to find the element 7 using linear search, starting from the beginning of the array? (A) 2 (B) 3 (C) 4 (D) 5 (E) 9 13. Suppose we have some distinct numbers between 1 and 1000 stored in a sorted array, and we want to search the number 500 using binary search. Which of the following is a valid binary search sequence? (A) 100, 400, 300, 600, 500 (B) 400, 800, 700, 600, 500 (C) 200, 100, 600, 800, 500 (D) 300, 900, 700, 800, 500 (E) None of the above 14. Assume A to be an array of integers (e.g., “int A[5] = {1, 2, 3, 4, 5};”). Indicating equivalence by ‘≡’, which of the following statements is incorrect? (A) A[i] ≡ ∗(A + i) (B) A ≡ &A[0] (C) &A[i] ≡ A + i (D) (i − j) ≡ (&A[i] − &A[j]) (E) None of the above 15. Identify the data structure (among the following ones) that consumes the highest amount of space to store a set of n integers. Assume that n is large. [Note: Consider the most space-efficient implemen- tation of each data structure.] (A) One-dimensional array (B) Singly linked-list (C) Doubly linked-list (D) Stack (E) Queue 16. What will be the output for the code segment below? #include <stdio.h> int main () { int a[] = {10, 20, 30, 40, 50}; int i; for(i=0; i<5; ++i) printf("%d,", *(a+i)); printf("n"); return 0; } (A) 10, 10, 10, 10, 10, (B) 10, 20, 30, 40, (C) 10, 20, 30, 40, 50, (D) Garbage values (E) None of the above 17. What will be the output for the code segment below? #include <stdio.h> int main () { int a[3][3] = {1,2,3,4,5,6,7,8,9}; int *ptr [3] = {a[0],a[1],a[2]}; int i; for(i=0; i<3; ++i) printf("%d,", *ptr[i]); return 0; } (A) 1, 1, 1, (B) 1, 2, 3, (C) 1, 4, 7, (D) Garbage values (E) None of the above
  • 3. 3 18. What will be the output for the code segment below? #include <stdio.h> typedef struct { int i; float f; } values; int main () { values var ={555 , 67.05501}; printf("%d ,%.2f", var.i, var.f); return 0; } (A) 555, 67 (B) 555, 67.06 (C) 555, 67.05 (D) 555, 67.05501 (E) None of the above 19. The output of the following code segment is 0x7fff70b4e3b0, . Choose the correct option for filling up the blank. #include <stdio.h> void main () { int a[5] = {10, 20, 30, 40, 50}; printf("%p,%pn", a, &a); } (A) 0x7fff70b4e3b0 (B) 10 (C) Address of the location containing 0x7fff70b4e3b0 (D) Compile time error (E) None of the above 20. Given an array A = {10, 30, 40, 50, 20}, calculate the number of swap operations required to sort the ele- ments in an increasing order using Bubble sort. (A) 1 (B) 2 (C) 3 (D) 4 (E) 5 21. Given an array A = {10, 20, 30, 40, 50}, calculate the number of comparisons (between elements) required to sort the elements in an increasing order using the most efficient implementation (one that requires the minimum number of comparisons in the best-case) of Bubble sort. (A) 0 (B) 4 (C) 5 (D) 9 (E) 10 22. The following program will create a file file.txt. What will be the content of the file.txt after the execution of the program? #include <stdio.h> int main () { FILE *fp; fp = fopen("file.txt","w+"); fputs("abcdef", fp); fseek(fp , -2, 1); fputs("pqrst", fp); fclose(fp); return (0); } (A) abcdefpqrst (B) abcdepqrst (C) abcdefqrst (D) abcdpqrst (E) None of the above 23. What will be the output for the code segment below? #include <stdio.h> #include <string.h> int main () { char str1 [15]; char str2 [15]; int ret; strcpy(str1 , "aAbBcC"); strcpy(str2 , "aABbcC"); ret = strcmp(str1 , str2 ); if(ret > 0) printf("str2 <str1"); else if(ret < 0) printf("str1 <str2"); else printf("str1=str2"); return (0); } (A) str2<str1 (B) str1<str2 (C) str1=str2 (D) Compile time error (E) None of the above 24. Given an array A = {40, 30, 10, 50, 20}, calculate the number of swap operations required to sort the el- ements in an increasing order using Selection sort that requires O(1) (constant) worst-case space com- plexity, i.e., does not use an auxiliary array. (A) 1 (B) 2 (C) 3 (D) 4 (E) 5
  • 4. 4 25. Given an array A = {10, 20, 30, 40, 50}, calculate the number of comparisons (between elements) required to sort the elements in an increasing order using in- sertion sort. (A) 0 (B) 4 (C) 5 (D) 9 (E) 10 26. Consider an array A = {329, 457, 657, 839, 436, 720, 355}, which we are trying to sort using radix sort starting from the least significant digit, using 3 it- erations. What would be the order of the elements after the second iteration? (A) {720, 355, 436, 457, 657, 329, 839} (B) {720, 329, 436, 839, 355, 457, 657} (C) {720, 329, 436, 839, 457, 355, 657} (D) {720, 329, 839, 436, 457, 355, 657} (E) None of the above 27. Which of the following sorting algorithms is stable? (A) Insertion sort (B) Bubble sort (C) Counting Sort (D) All of the above (E) None of the above. 28. Consider an empty stack S in which the follow- ing sequence of operations are performed: Push(4), Push(6), Pop(), Push(8), Push(9), Push(1), Push(2), Pop(). Which of the elements are present in the stack after the above operations? (A) 4, 6, 8, 9 (B) 4, 8, 9, 1 (C) 8, 9, 1, 2 (D) 6, 8, 9, 1 (E) None of the above 29. Consider an empty queue Q in which the following sequence of operations are performed: Enqueue(4), Enqueue(6), Dequeue(), Enqueue(8), Enqueue(9), Enqueue(1), Enqueue(2), Dequeue(). Which of the elements are present in the queue after the above operations? (A) 4, 6, 8, 9 (B) 4, 8, 9, 1 (C) 8, 9, 1, 2 (D) 6, 8, 9, 1 (E) None of the above 30. What will be the output for the code segment below? #include <stdio.h> void swap1(int a, int b) { int temp; temp = a; a = b; b = temp; } void swap2(int *a, int *b) { int temp; temp = *a; *a = *b; *b = temp; } void main () { int i=10, j=20, k=30, l=40; swap1(i, j); swap2 (&k, &l); printf("%d,%d,%d,%dn",i,j,k,l); } (A) 10, 20, 30, 40 (B) 20, 10, 30, 40 (C) 10, 20, 40, 30 (D) 20, 10, 40, 30 (E) None of the above 31. Consider a singly linked list L in which every node (structure) consists of two members. The first mem- ber is an integer data d. Identify the correct data type for the second member. (A) Integer (B) Pointer to an integer (C) Pointer to a pointer to an integer (D) Pointer to a node (E) None of the above 32. Identify the number of bytes required to store the string “This is an easy question” in a C program. (A) 20 (B) 21 (C) 24 (D) 25 (E) None of the above 33. Given an integer array declared by “int A[3][5];”, which of the following statements does not repre- sent the element A[2][3]? (A) (∗(A[2] + 3)) (B) (∗(A + 2))[3] (C) (∗((∗(A + 2)) + 3)) (D) (A[2] + 3) (E) None of the above
  • 5. 5 34. Given an integer array declared by “int A[ ] = {2, 4, 6, 8, 3};”, what is the value of A[A[1]]? (A) 2 (B) 4 (C) 6 (D) 8 (E) 3 35. Identify the 2’s complement representation of the negative integer −127, using 8 bits. (A) 10000001 (B) 11111111 (C) 01111111 (D) 10000000 (E) None of the above 36. The number of 1’s in the binary representation of the integer 13 ∗ 163 + 11 ∗ 162 + 9 ∗ 16 + 3 is: (A) 7 (B) 8 (C) 9 (D) 10 (E) None of the above 37. Given an integer array declared by “int A[10];”, what is the value of ((&A[2])−(&A[6]))? Assume that an integer takes 4 bytes. (A) −4 (B) −16 (C) 4 (D) 16 (E) None of the above 38. If two pointers p1 and p2 are declared by “int *p1, *p2;”, identify the invalid statements. (A) p1 = p1 + 2; (B) p1 = p1 − 2; (C) p1 = p1 ∗ 2; (D) int i = p1 − p2; (E) None of the above 39. Consider a singly linked-list with a head and a tail pointer (i.e., pointers to the first and last node in the list). Given this representation, which of the follow- ing operations can not be implemented in constant time (i.e., O(1) time)? (A) Insert an item at the front of the list (B) Insert an item at the rear of the list (C) Delete the front item from the list (D) Delete the rear item from the list (E) None of the above 40. Consider the following code segment. Identify the invalid statement to assign a value to member1. #include <stdio.h> struct test{ int member1; } var; void main () { struct test *ptr=&var; /* identify the invalid statement.*/ } (A) (*ptr).member1=5; (B) *ptr.member1=5; (C) (ptr)->member1=5; (D) ptr->member1=5; (E) None of the above 41. In C programming, the return type of a malloc() function is (A) An integer (B) A void pointer (C) A pointer to an integer (D) Pointer to an array (E) None of the above 42. What is the equivalent pointer expression for refer- ring the array element A[i][j][k][l] in an integer array A[10][10][10][10]? (A) ((((A+i)+j)+k)+l) (B) (*(*(*(*(A+i)+j)+k)+l)) (C) (((A+i)+j)+k+l) (D) ((A+i)+j+k+l) (E) None of the above 43. In C programming, the size of a union is determined by the size of the . (A) First member in the union (B) Last member in the union (C) Maximum-sized member in the union (D) Sum of the sizes of all members (E) None of the above 44. The C syntax for command-line argument is “int main(int argc, char *argv[ ])”. What is indicated by argv[0] in command-line arguments? (A) The name by which the program is invoked (B) The name of the files which are passed to the program (C) Count of the arguments in argv[ ] vector (D) Both A and B (E) None of the above
  • 6. 6 45. In C programming, the size of a structure is deter- mined by the size of the , excluding the slack bytes. (A) First member in the structure (B) Last member in the structure (C) Maximum-sized member in the structure (D) Sum of the sizes of all members (E) None of the above 46. The deletion of a node can always be done in con- stant (i.e., O(1)) time from a linked list with n nodes if . (A) The linked list is singly and the element stored in the node to be deleted is given (B) The linked list is singly and the pointer to the node to be deleted is given (C) The linked list is doubly and the element stored in the node to be deleted is given (D) The linked list is doubly and the pointer to the node to be deleted is given (E) None of the above 47. In C programming, identify the valid declaration of a three-dimensional array. (A) int A[ ][2][2]={2,2,2,2}; (B) int A[ ][ ][2]={2,2,2,2}; (C) int A[2][2][ ]={2,2,2,2}; (D) Both A and B (E) Both A and C 48. Which of the following code segments is invalid? (A) int A[20]; printf(“%p”, A+1); (B) int A[20]; printf(“%p”, (&A)+1); (C) int A[20]; printf(“%p”, (&(&A)+1)); (D) Both B and C (E) None of the above 49. Consider the C code below. How many ‘*’ will be printed by the following program? #include <stdio.h> void quiz(int i) { if (i > 1) { quiz(i / 2); quiz(i / 2); } printf("*"); } void main () { quiz (5); } (A) 3 (B) 5 (C) 7 (D) 9 (E) None of the above 50. Consider the C code below. How many ‘*’ will be printed by the following program? #include <stdio.h> void quiz(int i) { if (i > 1) { quiz(i % 2); quiz(i / 2); } printf("*"); } void main () { quiz (6); } (A) 3 (B) 4 (C) 6 (D) 7 (E) None of the above