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

SRM Institute of Science and Technology

The document contains information about the question bank for the subject 18CSS101J - Programming for Problem Solving for the II semester B.Tech/CSE program at SRM Institute of Science and Technology. It includes the course outcomes, topics covered in Unit III such as 2D arrays, strings, functions, and pointers. It also provides a sample set of 23 multiple choice questions assessing different cognitive levels related to these topics.

Uploaded by

suhas kollipara
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)
125 views

SRM Institute of Science and Technology

The document contains information about the question bank for the subject 18CSS101J - Programming for Problem Solving for the II semester B.Tech/CSE program at SRM Institute of Science and Technology. It includes the course outcomes, topics covered in Unit III such as 2D arrays, strings, functions, and pointers. It also provides a sample set of 23 multiple choice questions assessing different cognitive levels related to these topics.

Uploaded by

suhas kollipara
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/ 7

SRM INSTITUTE OF SCIENCE AND TECHNOLOGY

Ramapuram Campus, Bharathi Salai, Ramapuram, Chennai - 600089

FACULTY OF ENGINEERING AND TECHNOLOGY

DEPARTMENT OF
COMPUTER SCIENCE AND
ENGINEERING

QUESTION BANK

DEGREE / BRANCH: B.Tech/CSE

II SEMESTER

18CSS101J – Programming for Problem Solving

Regulation – 2018

Academic Year 2021-2022


SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Ramapuram Campus, Bharathi Salai, Ramapuram, Chennai-600089

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

QUESTION BANK

SUBJECT : 18CSS101J – Programming for Problem Solving


SEM/ YEAR: II/ I
Course Outcomes
CO1: Identify methods to solve a problem through computer programming. List the basic data types
and variables in C
CO2: Apply the logic operators and expressions. Use loop constructs and recursion. Use array to store
and retrieve data
CO3: Analyze programs that need storage and form single and multi-dimensional arrays. Use
preprocessor constructs in C
CO4: Create user defined functions for mathematical and other logical operations. Use pointer to
address memory and data
CO5: Create structures and unions to represent data constructs. Use files to store and retrieve data
CO6: Apply programming concepts to solve problems. Learn about how C programming can be
effectively used for solutions
UNIT III
Initializing and Accessing 2D Array-Initializing Multidimensional Array-Array Programs – 2D-Array
Contiguous Memory-Array Advantages and Limitations-Array construction for real-time application-Common
Programming errors-String Basics-String Declaration and Initialization-String Functions: gets(), puts(),
getchar(), putchar(), printf()-String Functions: atoi, strlen, strcat, strcmp-String Functions: sprint, sscanf, strrev,
strcpy, strstr, strtok
Arithmetic Characters on Strings - Functions declaration and definition - Types: Call by Value, Call by
Reference P - Function with and without Arguments and no Return Values - Function with and without
Arguments and
Return Values - Recursion Functions
PART-A (Multiple Choice Questions)
Q. Questions Course Competence
No Outcome BT Level
1 1. The 2D array is organized as matrices which can be represented as the
collection of _______ and ________
A. rows and column CO 3 BT 1
B. leafs and tuples
C. records and fields
D. data and operators
ANSWER: A
2 In the 1D array, we don't need to specify the size of the array if the
declaration and initialization are being done simultaneously. However, this
will not work with 2D arrays. We will have to define at least the CO 3 BT 1
__________ dimension of the array.
A. first
B. second
C. third
D. fourth
ANSWER: B
3 Total memory allocated to an Array =
A. Number of elements * size of one element
B. Number of elements * Number of elements CO 3 BT 1
C. size of one element * size of another element
D. Number of elements
ANSWER: A
4 In this ________ method all the first column elements are stored first,
followed by second column elements and so on.
A. row major order CO 3 BT 1
B. column major order
C. row column major order
D. column row major order
ANSWER: B
5 The _______ can be defined as the one-dimensional array of characters
terminated by a null ('\0').
A. structure CO 3 BT 1
B. array
C. string
D. float
ANSWER: C
6 The string literal cannot be reassigned to another set of characters.
A. True
B. False CO 3 BT 1
C. True and False
D. Always False
ANSWER: A
7 Eg. char st[20]; We do not need to use address of (&) operator in scanf to
store a string since string st is an array of characters and the name of the
array, i.e., st indicates the _______of the string (character array) therefore CO 3 BT 2
we need not use & with it.
A. base address
B. last address
C. middle address
D. label
ANSWER: A
8 The ________ is a variable which stores the address of another variable.
A. array
B. char CO 3 BT 1
C. pointer
D. union
ANSWER: C
9 The _______ accepts the space-separated strings.
A. fscanf()
B. printf() CO 3 BT 1
C. gets()
D. puts()
ANSWER: C
10 _________ returns the length of string name.
A. strlen()
B. strcat() CO 3 BT 1
C. strstr()
D. length()
ANSWER: A
11 strcmp() compares the first string with second string. If both strings are
same, it returns __________.
A. 0 CO 3 BT 1
B. 1
C. 2
D. 3
ANSWER: A
12 sprintf(buffer, "Sum of %d and %d is %d", a, b, c);
A. prints the values of a, b, c on to the console
B. Instead of printing on console, it store output on char buffer which are CO 3 BT 1
specified in sprintf.
C. prints the values of a, b, c onto the air space
D. None of the above
ANSWER: B
13 A _________ is a group of statements that together perform a task
A. main
B. data type CO 3 BT 1
C. void
D. function
ANSWER: D
14 If a function is to use arguments, it must declare variables that accept the
values of the arguments. These variables are called the _________
parameters of the function. CO 3 BT 1
A. actual
B. regular
C. formal
D. virtual
ANSWER: C
15 _________method copies the address of an argument into the formal
parameter
A. Call by Value CO 3 BT 1
B. Call by Address
C. Call by WhatsApp
D. Call by Zoom
ANSWER: B
16 Any function which calls itself is called _________function
A. tower
B. iterative CO 3 BT 1
C. recursive
D. None of the above
ANSWER: C
17 Choose all the correct ways to declare the function which is intended to
receive an array as an argument.
A. return_type function(type arrayname[]) ; CO 3 BT 1
B. return_type function(type arrayname[SIZE])
C. return_type function(type *arrayname)
D. All of the above
ANSWER: D
18 Identify the wrong disadvantage of an Array:
A. Compiler will reserve, the declared Memory Space
B. Programmers, need to know well ahead, about the amount of Memory CO 3 BT 1
Space, to be used.
C. When we try to exceed the Limit of Memory Space, our program will
land up in a Trouble.
D. Store and Retrieve the Data, in an organized manner.
ANSWER: D
19 How do you initialize an array in C?
A) int arr[3] = (1,2,3);
B) int arr(3) = {1,2,3}; CO 3 BT 1
C) int arr[3] = {1,2,3};
D) int arr(3) = (1,2,3);
ANSWER: C
20 Predict the output of below program:
#include <stdio.h>
int main() CO 3 BT 3
{
int arr[5];

// Assume that base address of arr is 2000 and size of integer


// is 32 bit
arr++;
printf("%u", arr);

return 0;
}
(A) 2002
(B) 2004
(C) 2020
(D) lvalue required
ANSWER: D
21 Choose the correct output of the following code:
#include <stdio.h>
int main() CO 3 BT 3
{
int arr[5];
// Assume base address of arr is 2000 and size of integer is 32 bit
printf("%u %u", arr + 1, &arr + 1);

return 0;
}
(A) 2004 2020
(B) 2004 2004
(C) 2004 Garbage value
(D) The program fails to compile because Address-of operator
cannot be used with array name
ANSWER: A
22 Choose the correct output of the following code:
# include <stdio.h>
void print(int arr[]) CO 3 BT 3
{
int n = sizeof(arr)/sizeof(arr[0]);
int i;
for (i = 0; i < n; i++)
printf("%d ", arr[i]);
}

int main()
{
int arr[] = {1, 2, 3, 4, 5, 6, 7, 8};
print(arr);
return 0;
}
(A) 1, 2, 3, 4, 5, 6, 7, 8
(B) Compiler Error
(C) 1 2
(D) Run Time Error

ANSWER: C
23 Choose the correct output of the following code:
#include<stdio.h>
int main() CO 3 BT 3
{
int a[] = {1, 2, 3, 4, 5, 6};
int *ptr = (int*)(&a+1);
printf("%d ", *(ptr-1) );
return 0;
}
(A) 1
(B) 2
(C) 6
(D) Runtime Error
ANSWER: C
24 Consider the following C-function in which a[n] and b[m] are two
sorted integer arrays and c[n + m] be another integer array.
void xyz(int a[], int b [], int c[]) CO 3 BT 3
{
int i, j, k;
i = j = k = O;
while ((i<n) && (j<m))
if (a[i] < b[j]) c[k++] = a[i++];
else c[k++] = b[j++];
}
Which of the following condition(s) hold(s) after the termination of
the while loop?
(i) j < m, k = n+j-1, and a[n-1] < b[j] if i = n (ii) i < n, k = m+i-1,
and b[m-1] <= a[i] if j = m (A) only (i)
(B) only (ii)
(C) either (i) or (ii) but not both
(D) neither (i) nor (ii)
ANSWER: D
25 Assume the following C variable declaration
int *A [10], B[10][10];
Of the following expressions CO 3 BT 3
I A[2]
II A[2][3]
III B[1]
IV B[2][3]
which will not give compile-time errors if used as left hand sides of
assignment statements in a C program?

(A) I, II, and IV only


(B) II, III, and IV only

(C) II and IV only


(D) IV only
ANSWER: A
PART B (4 Marks)

1 Describe the two dimensional array declaration and initialization process? CO3 BT 2
2 List the Array advantages and limitations. CO3 BT 2

3 How will your declare and initialize Strings? CO3 BT 2

4 Elucidate the usage of the String Functions: atoi, strlen, strcat, strcmp? CO3 BT 3

5 Describe the Functions declaration and definition with the suitable syntax? CO3 BT 2

6 Write short notes on Recursion Functions? CO3 BT 2

7 How to store and retrieve the arithmetic characters on Strings? CO3 BT 2

8 List and describe the common programming errors in using arrays. CO3 BT 3
PART C (12 Marks)

1 Explain the String Functions: gets(), puts(), getchar(), CO3 BT 3


putchar(), printf() – with the syntax and example.
2 Explain the String Functions: sprint, sscanf, strrev, CO3 BT 3
strcpy, strstr, strtok – with the proper syntax and example.
3 Define Function and explain its types: Call by Value, Call by Reference CO3 BT 3
with the appropriate example
4 Explain the array construction process. Cite an example of real-time CO3 BT 3
application where the array is used, along with the source code.
5 Explain the following: CO3 BT 3
1. Function with and without Arguments and no Return Values
2. Function with and without Arguments and Return Values
Support your explanation with the example code.

Note:

1. BT Level – Blooms Taxonomy Level

2. CO – Course Outcomes

BT1 – Remember BT2 – Understand BT3 – Apply BT4 – Analyze BT5 – Evaluate BT6 – Create

You might also like