100% found this document useful (1 vote)
116 views24 pages

20CSS01 PPS Question Bank

The document is a question bank for the subject "Programming for Problem Solving" belonging to the academic year 2020-2021 for the B.E. Computer Science & Engineering program at SRI KRISHNA COLLEGE OF TECHNOLOGY. It contains 50 multiple choice questions related to programming concepts in C language such as data structures, algorithms, functions, pointers etc.

Uploaded by

CHIRANJEEVI V
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
116 views24 pages

20CSS01 PPS Question Bank

The document is a question bank for the subject "Programming for Problem Solving" belonging to the academic year 2020-2021 for the B.E. Computer Science & Engineering program at SRI KRISHNA COLLEGE OF TECHNOLOGY. It contains 50 multiple choice questions related to programming concepts in C language such as data structures, algorithms, functions, pointers etc.

Uploaded by

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

SRI KRISHNA COLLEGE OF TECHNOLOGY

An Autonomous College, Accredited by NAAC with “A” grade


Coimbatore, Tamil Nadu
Academic Year 2020-2021 (ODD SEM)
B.E. Computer Science & Engineering

20CSS01-PROGRAMMING FOR PROBLEM SOLVING


Question Bank

1 Identify the error in the code:


struct Student{
char[20] name;
int rollno;
struct Student s2; };
a) Linker Error
b) Error: in structure declaration
c) No Error
d) none of the above
2 Self referential structures with multiple link can have___________self –pointers
a) only one
b) multiple
c) no
d) null
3 ______ links object code with libraries, creates output and stores it on disk.
a) Editor
b) Preprocessor
c) Compiler
d) Linker
4 ___________ is the syntax for strlen() function.
a) var=strlen(string);
b) var=string(strlen);
c) Strlen
5 Self-referential structures are very useful in creation of other complex data structures
a) Stack
b) Queue
c) Linked list
d) all of the above
6 #include <stdio.h>
int fibonacci(int i) {
if(i == 0) {
return 0; }
if(i == 1) {
return 1; }
return fibonacci(i-1) + fibonacci(i-2);}
int main() {
int i;
for (i = 0; i < 4; i++) {
printf("%d\t\n", fibonacci(i)); }
return 0;} What is the output of the above code?
a) 0101
b) 0112
c) 011144
d) 0112223
7 #include <stdio.h>
unsigned long long int factorial(unsigned int i) {
if(i <= 1) {
return 1; }
return i * factorial(i - 1);}
int main() {
int i = 12;
printf("Factorial of %d is %d\n", i, factorial(i));
return 0;} What is the output of above code?
a) Factorial of 12 is 479001600
b) Factorial of 12 is 12
c) Factorial of 12 is 12 11 10 9 8 7 6 5 4 3 2 1
d) None
8 A specific element in an array is accessed by ____________________.
a) an Index
b) a value
c) an address
d) a name
9 Which of the following cannot be the first character of the C identifier?
a) Letter
b) An underscore
c) A digit
10 The C statement “”if (a == 1 || b == 2) {}”” can be re-written as ___________
a) if (a == 1)if (b == 2){}
b) if (a == 1){}else if (b == 2){}
c) if (a == 1){}if (b == 2){}
d) None of the above
11 Which is an example for 2-dimensional array?
a) matrix representation
b) table representation
c) Both Matrix and table representation
d) None of the above
12 What is the only function all C programs must contain?
a) start()
b) system()
c) main()
d) program()
13 __________ statement is encountered inside a loop, the control directly comes out of
loop and the loop gets terminated.
a) do while
b) jump
c) switch case
d) for
14 The __________ represents which operator should be evaluated first if an expression is
containing more than one operator with the same priority.
a) Priority
b) Associativity
c) Expression
15 fprintf() is used for
a) Write to a text file
b) reading to a text file
c) append
d) none of the above
16 What is the default return type if it is not specified in function definition?
a) void
b) int
c) float
d) short int
17 The keyword used to transfer control from a function back to the calling function is
a) switch
b) goto
c) go back
d) return
18 The technique used in Merge sort is
a) backtracking
b) greedy algorithm
c) dynamic programming
d) divide and conquer
19 The continue statement cannot be used with ________
a) while
b) do while
c) switch
20 "Predict the output for the given program: int main() { char str[25];
scanf(""%s"", str); printf(""%s"",str); return 0; } //input: Programming PPS"
a) Programming
b) PPS
c) P
d) Compilation error
21 What function is employed in merge sort?
a) Function
b) Recursion function
c) None
22 The order in which the merge sort work
a) partition, merge
b) merge, partition
c) only partition
d) only merge
23 Pointers are variables that hold the
a) address of another variable of same data type.
b) none value
c) address of another variable of different data type.
d) value only
24 Changing the value of Array elements is possible in C language.
a) True
b) False
25 Identify the operator which is used to declare the pointer
a) *
b) &
c) %
d) $
26 The pointer associated with closing the file returns
a) 0 if file not found
b) EOF if error
c) 0 if the file is closed successfully
d) both b and c
27 The disadvantage of linear search is ______________________
a) When large number of elements are there in an array
b) Simplicity
c) easy to implement
d) Does not require order of elements
28 Problem solving is
a) Process of analyzing the problem
b) Deriving a solution for the problem
c) Appropriate use of problem-solving Strategies, Techniques and Tools
d) All the above
29 The number of memory cells required to store a data item depends on its
_____________
a) Variable
b) Identifier
c) Datatype
d) Constant
30 What will be the output of the following C code?
# include <stdio.h>
int main() {
void foo();
printf("1 ");
foo(); }
void foo() {
printf("2 "); }
a) Compile time error
b) 1 2
c) 1 2 1 2
d) depends on the compiler
31 The roots of the quadratic equation 6x² – x – 2 = 0 are
a) 0.67,0.5
b) -0.67,0.5
c) -0.67,-0.5
d) 0.67,-0.5
32 What is the output of C Program.?
int main()
{
int a[] = {1,2,3,4};
int b[4] = {5,6,7,8};
printf(""%d,%d"", a[0], b[0]);
}
a) 2,6
b) 1,5
c) 0,0
d) Compiler Error
33 Which is the correct way of declaring 2d matrix?
a) datatype arrayname[row];
b) datatype arrayname[row][col];
c) datatype arrayname[columns];
d) datatype arrayname[col][row];
34 If x > arr[mid], Then which pointer position need to change
a) high=mid-1
b) high=mid+1
c) low=mid-1
d) low=mid+1
35

a) 12345678910
b) 1234678910
c) 123456789
d) 1234578910
36 Which of these best describes an array?
a) A data structure that shows a hierarchical behavior
b) Container of objects of similar types
c) Arrays are immutable once initialized
d) Array is not a data structure
37 If the following code is executed how many times ""Hello"" will be printed?
int main()
{
int k = 0;
for (k = 0; k < 3; k++)
printf(""Hello"");
}
a) Once
b) Twice
c) Thrice
d) Compile Error
38 A merge sort
a) Divides the unsorted array into 3 sublists of equal size
b) Divides the unsorted array into 2 sublists of equal size
c) Divides the unsorted array into 4 sublists of equal size
d) Divides the unsorted array into 5 sublists of equal size
39 The system allocates memory location(s) to hold the ____________ of the variable
a) Address
b) Name
c) Value
d) Data type
40 Which of the following statement is false?
a) Merge sort keeps on dividing the list into equal halves until it can no more be divided.
b) Merge sort combines the smaller sorted lists keeping the new list sorted too.
c) Based on Merge sort definition, if it is only one element in the list, it is sorted.
d) Merge sort works on backtracking technique
41 Fill in the missing line for the following pseudocode
To find Area Of Rectangle()
Begin
Read: width, length;

Print area
End
a) area=length*breadth
b) area
c) area=length*width
d) area=l*b
42 Which of the following shows the correct syntax for an if statement?
a) if expression
b) if { expression
c) if ( expression )
d) expression if
43 The parameters passed to function are called
a) Formal Parameters
b) Actual Parameters
c) Call Back Parameters
d) Return Parameters
44 Predict the Output for the given Program:
int main(){
struct ship {
int size;
char color[10]; }
boat1, boat2;
boat1.size=10;
boat2 = boat1;
printf("boat2=%d",boat2.size);
return 0;}
a) boat2=0
b) boat2=-1
c) boat2=10
d) Compiler error
45 Identify the operators used in pointers
a) *,&
b) <,>
c) #,%
d) &,}
46 Identify the reference operator
a) &
b) <,>
c) #
d) *
47 What is an internal sorting algorithm?
a) Algorithm that uses tape or disk during the sort
b) Algorithm that involves swapping
c) Algorithm that uses main memory during the sort
d) Algorithm that are considered ‘in place’
48 Identify what type of error for the given program.

a) Syntax Error
b) Logical Error
c) Run time Error
d) All of the above
49 Which is the last phase of a six step problem solving Loop?
a) Build and test the ideas
b) Identify the problem
c) Analysing the problem
d) Evaluating the Results
50 ________ statement is used to transfer the flow of control to any part of the program
desired.
a) do while
b) while
c) for
d) jump
51 ______________is the process of finding the location of the specified element in a list.
a) Sorting
b) Array
c) Searching
d) String
52 "Predict The output:
int main()
{
if( 8 > 19 )
{
printf(""Times up..."");
}
printf(""Yes"");
return 0;
}"
a) Yes
b) Times up Yes
c) Times up... Yes
d) Times up...
53 The format identifier %c is also used for _____ data type?
a) Integer
b) Float
c) Character
54 How do you initialize an array in C?
a) int arr[3] = (1,2,3);
b) int arr(3) = [1,2,3];
c) int arr[3] = {1,2,3};
d) int arr{3} = (1,2,3);
55 Associativity of ++, -- and ! Operators in expressions evaluation are from ________.
a) left to right
b) right to left
c) left alone
d) right alone
56 Which among the following is the is a simpler version of a programming code?
a) Algorithm
b) Pseudocode
c) Flowchart
d) Syntax
57 The number of tokens in the following C statement is
printf("i = %d”,i);
a) 7
b) 8
c) 9
d) 10
58 Which of the following will always provide you the guaranteed solution for the given
problems?
a) Algorithmic
b) Heuristic
c) Trial and error
d) All the above
59 Each Variable is having _______________address
a) Same
b) Unique
c) Identical
d) Alike
60 ________ compiles the program for the same architecture that is running on.
a) Native compiler
b) Cross compiler
c) Both 1 & 2
61 Identify the memory address

a) Num
b) 10
c) 0x7fff5694dc58
62 Missing out of Quotes and Brackets in the source code is called as ____________.
a) Syntax Error
b) Logical Error
c) Run time Error
d) All of the above
Answer: Constist
63 Gmail, YouTube, Whatsapp are categorized under which of the following Software
Types?
a) System Software
b) Application Software
c) Programming Software
d) Driver Software
64 Identify the file extension for source code, object code and executable file.
a) .c, .bak, .o
b) .c, .o, .ae
c) .c, .obj, .exe
d) .c, obj, .o
65 int x=40;
main(
{
int x=20;
printf("%d",x);
}
Which is a global variable?
a) 40
b) 20
c) Both
d) None
66 Associativity of C Operators *, /, %, +, - and = is.?
a) Operators *, / and % have Right to Left Associativity. Operators + and - have Left to
Right Associativity. Operator = has Right to Left Associativity.
b) Operators *, / and % have Left to Right Associativity. Operators + and - have Left to
Right Associativity. Operator = has Right to Left Associativity
c) Operators *, / and % have Right to Left Associativity. Operators + and - have Right to
Left Associativity. Operator = has Right to Left Associativity
d) Operators *, / and % have Right to Left Associativity. Operators + and - have Right to
Left Associativity. Operator = has Left to Right Associativity
67 "_________ is the minimum and maximum Indexes of this below array. int main(){int
ary[9];return 0;}
a) 0,8
b) -1,8
c) 1,9
d) -1,-8
68

a) m>n, m<n
b) m<n, m>n
c) m>=n, m<=n
d) m<=n, m>=n
69 Give the size(byte) of the variable pi allocated in memory

a) 2
b) 4
c) 6
d) 8
70 Which of the following is used to make an identifier/variable as a constant?
a) Volatile
b) Const
c) Signed
d) None
71 Linker takes the responsibility to combine __________ and __________ files to produce
an executable file.
a) Object file and Header file
b) Source file and Object file
c) Source file and Header file
d) Object file and .bak file
72 Left shift (<<) and Right shift (>>) operators are equivalent to _____________ by 2.
a) Multiplication and Division
b) Division and Multiplication
c) Multiplication and Remainder
d) Remainder and Multiplication
73 What will strcmp() function do?
a) compares the first n characters of the object b
b) compares the string
c) undefined function
d) copies the string
74 ____________search is a divide and conquer method/Techniques
a) Binary search
b) sequential search
c) random search
d) recursive search
75 Predict the output for the following:

a) \”
b) \
c) “
d) Compile Error
76 The C code ‘for(;;)’ represents
a) finite loop
b) infinite loop
c) iterative loop
77 #include<stdio.h>
void main()
{
int x = 10;
printf("%d", x);
}
Output of the code.
a) 10
b) -10
c) Compile time error
d) x
78 ++a is an example of
a) Pre increment
b) Post increment
c) Pre decrement
d) Post decrement
79 In a program, how the list of errors are identified and indicated by?
a) Running a program
b) Executing a program
c) Compiling a program
d) Output of a program
80 Identify the correct statement of logical errors:

a) S1 only
b) S2 only
c) S3 only
d) S4 only
81 Which is true for a, if a is defined as int a[10][20];?
a) a is true two-dimensional array
b) 200 int-sized locations have been set aside
c) an array contains 10 columns and 20 rows
d) an array contains 10 rows and 20 column
82 Which of the following is the correct order of evaluation for the below expression?
z=a+b*c/4%2–1
a) * / % + - =
b) = * / % + -
c) / * % - + =
d) * % / - + =
83 The post test loop among the following is
a) while
b) do...while
c) for
d) break
84 Which of the following is a sort in place algorithm?
a) Selection Sort
b) Insertion Sort
c) Bubble Sort
85 If an increment or decrement operator is placed after a variable it is called as
a) post increment
b) post decrement
c) pre increment & pre decrement
d) both a & b
86 Solve the below problem using a problem solving loop. Imagine you have 25 beads and
you have to make a three digit number on an abacus, you must use all the beads. How
many three digit numbers can you make?
a) 3
b) 4
c) 5
d) 6
87 int disp[2][4] = { 10, 11, 12, 13, 14, 15, 16, 17}; what is the value disp[0][1]?
a) 11
b) 14
c) 10
d) 17
88 Which of the following uses structure?
a) Array of structures
b) Linked List
c) Stacks
d) All of the Above
89 What will be the output of the following program

a) 0.0
b) 0.1
c) 0.2
d) 0.3
90 In this 2d array abc[5][4], how many elements can be stored?
a) 5
b) 4
c) 20
d) 9
91 "What will be the output of the following C code?"

a) 1 2 3 4 5 0
b) 1 2 3 4 5 junk
c) 1 2 3 4 5 5
d) Run time error
92 The output while executing the following statement : for(i = 2; i <= 6; i = i + 2) printf("%d\t",
i + 1);
a) 3 5 7
b) 3
c) 2 4 6
d) 7
93 Binary Search is a searching algorithm for finding an element's position in a
______________ array.
a) Random array
b) Sorted array
c) Unsorted array
d) Mixed array
94 Self referential structures with single link can have___________self –pointers
a) only one
b) multiple
c) No
d) two
95 A function that calls itself is known as
a) Self Referential
b) Looping
c) Iteration
d) Recursion
96 The exit condition which prevents the function from infinite looping is called as
a) Base Condition
b) Starter
c) Recurse
d) none
97 The mode ab+ in file handling signifies
a) open a text file in both reading and writing mode
b) close a binary file in both reading and writing mode
c) open a binary file in both reading and writing mode
d) close a text file in both reading and writing mode
98 While executing the C Program, the compiler memory is
a) volatile
b) non volatile
c) permanent
d) none of the above
99 The default parameter passing mechanism is
a) Call by value
b) Call by reference
c) Call by value result
d) None
100 square( ); is an example of

a) Function with argument without return type


b) Function with argument with return type
c) Function without argument without return type
d) Function without argument with return type
101 ____________ is a structure in C language.

a) A structure is a collection of elements that can be of same data type


b) A structure is a collection of elements that can be of different data type
c) Elements of structures are called members
d) All of the above
102 Which of the following keywords is used to define an alternate name for an already
existing data type?
a) default
b) typedef
c) static
d) volatile
103 ____________ is the general syntax for using typedef.

a) typedef <name> <alias_name>


b) typedef <existing_name> <alias_name>
c) typedef <alias_name> <existing_name>
d) typedef <existing_name>
104 Structures pointing to the same type of structures__________
a) Array of structure
b) Recursion
c) Self-referential structure
d) function
105 An example structure used the concept of self-referential structure is_________

a) files
b) linked list
c) conditional statements
d) arrays
106 First step in problem solving process is to

a) Design a Solution
b) Define a Problem
c) Practicing the Solution
d) Organizing the Data
107 ____________________ is a solution model to a given problem represented
diagrammatically.
a) Flowchart
b) Algorithm
c) Pseudo-code
d) All the Above
108 Which of the following are themselves a collection of different data types?

a) String
b) Structures
c) char
109 What does the Start/End symbol do?

a) Ends the program Only


b) Can be used to show the beginning or ending of a program
c) Visual representation of the entire program
d) Starts the program Only
110 Collection of multiple structure variables where each variable contains information about
different entities
a) Array of Functions
b) Nested Structures
c) Nested Arrays
d) Array of Structures
111 Which of the following cannot be a structure member?

a) Another structure
b) Function
c) Array
112 Set of instructions that mimic programming language instructions are called as
a) Flowchart
b) Algorithm
c) Pseudo-code
d) All the Above
113 Which of the following does not initialize ptr to null (assuming variable declaration of a
as int a=0;)?
a) int *ptr = &a;
b) int *ptr = &a – &a;
c) int *ptr = a – a;
114 When can algorithms be used?

a) Only with computers


b) To design a solution to any problem
c) For programming
115 What is the correct order of occurrence in a system flowchart?

a) input, output, process, feedback


b) feedback, input, output, process
c) input, process, output, feedback
d) output, feedback, input, process
116 What are the two main ways that algorithms can be designed?

a) Images or videos
b) In pseudocode or as a flowchart
c) By hardware or software
117 System flowcharts are used to show the direction of what?

a) Data
b) Information
c) Knowledge
118 Choose the right option
string* x, y;
a) x is a pointer to a string, y is a string
b) y is a pointer to a string, x is a string
c) Both x and y are pointer to string types
119 Which of the following true about FILE *fp

a) FILE is a keyword in C for representing files and fp is a variable of FILE type


b) FILE is a stream
c) FILE is a buffered stream
d) FILE is a structure and fp is a pointer to the structure of FILE type
120 Which of the following is true about return type of functions in C?
a) Functions can return any type
b) Functions can return any type except array and functions
c) Functions can return any type except array, functions and union
d) Functions can return any type except array, functions, function pointer and union
121 Which of the following is true about recursion?

a) Recursion provides a clean and simple way to write code.


b) The recursive program has less space requirements than iterative program
c) The principle of stack is FIFO
122 How many values can a C Function return at a time?

a) Only One Value


b) Maximum of two values
c) Maximum of three values
d) Maximum of 8 values
123 Choose the incorrect statement about merge sort from the following?

a) it is a comparison based sort


b) it is an adaptive algorithm
c) it is not an in place algorithm
124 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
125 Choose the right statement for fscanf() and scanf()

a) fscanf() can read from standard input whereas scanf() specifies a stream from which
to read
b) fscanf() can specifies a stream from which to read whereas scanf() can read only
from standard input
c) fscanf() and scanf() has no difference in their functions
d) fscanf() and scanf() can read from specified stream
126 What will happen when we use void in argument passing?

a) It will not return value to its caller


b) It will return value to its caller
c) both a & b are correct
127 An array Index starts with?

a) -1
b) 0
c) 1
d) 2
128 Select the best description to explain what a binary search algorithm is.

a) Put the elements in order, check each item in turn.


b) Put the elements in order, compare with the middle value, split the list in order and
repeat.
c) Elements do not need to be in order, compare to the middle value, split the list in
order and repeat
d) Elements do not need to be in order, check each item in turn
129 If switch feature is used, then

a) Default case must be present


b) Default case, if used, should be the last case
c) Default case, if used, can be placed anywhere
130 How do you accept a Multi Word Input in C Language.?

a) SCANF
b) GETS
c) GETC
d) FINDS

You might also like