Professional Documents
Culture Documents
Cse101 MCQ 1
Cse101 MCQ 1
1. What is the correct format for calling a function using Call by value
a. fun(a, b);
b. fun(&a, &b);
c. fun(*a, *b);
d. fun;
Answer: A
2. What is the correct format for calling a function using Call by reference
a. fun(a, b);
b. fun(&a, &b);
c. fun(*a, *b);
d. fun;
Answer: B
a. *
b. &
c. !
d. @
Answer: B
a. *
b. &
c. !
d. @
Answer: A
a. 5
b. 10
c. &a
d. &b
Answer: B
a. 5
b. 10
c. &a
Answer: B
a. The values of those variables are passed to the function so that it can manipulate them
b. The location of variable in memory is passed to the function so that it can use the same memory area
for its processing
c. The function declaration should contain ampersand (& in its type declaration
d. All of above
Answer B
8. Functions can be declared with default values in parameters. We use default keyword to specify the
value of such parameters.
a. True
b. False
Answer: False
9. If the type specifier of parameters of a function is followed by an ampersand (& that function call is
a. pass by value
b. pass by reference
Answer: B
10. In case of arguments passed by values when calling a function such as z=addidion(x,y),
a. Any modifications to the variables x & y from inside the function will not have any effect outside the
function.
b. The variables x and y will be updated when any modification is done in the function
Answer: B
Topic: UNFORMATTED INPUT / OUTPUT FUNCTIONS(answer is
in red)
1.What is the use of putchar()?
a) To write a character on standard output
b) To read a character from standard input.
c) Nothing
d) Both a & b
2.How many characters are dispalyed by putchar() on standard output at one time
a. 1
b. 2
c. 3
d. 0
a. 1
b. 2
c. 3
d. 0
A. strinit() B. strnset()
C. strset() D. strcset()
Answer: B
A. -1 B. 1
C. 0 D. Yes
Answer: C
3. The library function used to find the last occurrence of a character in a string is
A. strnstr() B. laststr()
C. strrchr() D. strstr()
Answer: C
4. Which of the following function is used to find the first occurrence of a given string in another string?
A.strchr() B.strrchr()
C.strstr() D.strnset()
Ans: C
5. Which of the following function is more appropriate for reading in a multi-word string?
A. printf(); B. scanf();
C. gets(); D. puts();
Answer: C
6. Which of the following statement is correct?
Answer: C
A.1, 2 B.1, 2, 3
C.2, 4 D.3, 4
Answer B
#include<stdio.h>
#include<string.h>
int main()
{
printf("%d\n", strlen("123456"));
return 0;
}
A. 6 B. 12
C. 7 D. 2
Answer: A
#include<stdio.h>
int main()
{
printf(5+"Good Morning\n");
return 0;
}
A. Good Morning B. Good
C. M D. Morning
Answer: D
10. The ____ string function replaces the contents of a string with the contents of another string.
a. strrep d. strchr
b. strcat
c. Strncpy
Answer: C
11. What will be output when you will execute following c code?
#include<stdio.h>
void main(){
printf("%s",arr);
b. The
c. The African
d. Compilation Error
Answer: D
#include<stdio.h>
void main()
{
if(str1 == str2)
printf("\n Equal");
else
printf("\nUnequal");
A.Equal
B. Unequal
Answer: B
#include<stdio.h>
void main()
char ch = 'A';
A. 1 1
B. 1 4
C. 4 4
Answer: B
.14. The ____ string manipulation function determines if a character is in a string.
a. strlen c. strcat
b. strcmp d. strchr
Answer: D
b. As long as they are identically declared, including their length, one string may be
assigned to another.
d. When a string is initialized, we do not need to specify the size of the array.
Answer: B
Topic: Arrays
1. The elements of a single dimensional array can be accessed by using
a. Multi subscript
b. Single subscript
c. Both
d. None
Answer: B
Answer: A
Answer: C
Answer: B
Answer: B
Answer: C
Answer: A
Answer: A
9. Do array used for maintaining multiple variable names using same name
a. No
b. Yes
c. Both
d. None
Answer: B
Answer: B
11. What will be the output for program
#include<stdio.h>
int main( )
{
int a[1]={10};
printf(“%d”,0[a]);
return 0;
}
a. 1
b. 10
c. 0
d. None of above
Answer: B
Answer: C
Answer: B
Answer: B
Answer: 4
Topic : searching and sorting techniques
Q1. The operation of processing each element in the list is known as
a. Sorting
b. Merging
c. Inserting
d. Traversal
Answer: d
Q2. Finding the location of the element with a given value is:
a. Traversal
b. Search
c. Sort
d. None of above
Answer: b
Answer: a
Q4.Each array declaration need not give, implicitly or explicitly, the information about
a. the name of array
b. the data type of array
c. the first data from the set to be stored
d. the index set of the array
Answer: c
Answer: a
Q8. Which of the following is not the required condition for binary search algorithm?
a. The list must be sorted
b. there should be the direct access to the middle element in any sublist
c. There must be mechanism to delete and/or insert elements in list
d. none of above
Answer: c
________________________________________
Q9. Which of the following is not a limitation of binary search algorithm?
a. must use a sorted array
b. requirement of sorted array is expensive when a lot of insertion and deletions are needed
c. there must be a mechanism to access middle element directly
d. binary search algorithm is not efficient when the data elements are more than 1000.
Answer: d
Answer: a
Answer: c
Q12.Which among the following is the best when the list is already sorted ?
1. Insertion sort
2. Bubble sort
3. Merge sort
4. Selection sort
Answer: b
Topic: Storage classes
1. The various storage classes are
a) auto
b) extern
c) static
d) All of the above
Answer d
2. Storage class specifies
a) Storage duration of a variable
b) Scope of variable
c) Storage
d) All of the above
Answer d
3. The default storage class is
a) auto
b) extern
c) static
d) register
Answer a
4. The default initial value of an auto storage class variable is
a) 0
b) 1
c) 22
d) Garbage Value
Answer d
5. The register class storage variables are stored in
a) Memory
b) Hard disk
c) Memory card
d) CPU registers
Answer d
6. The default initial value of an static storage class variable is
a) 0
b) 1
c) Garbage value
d) NULL
Answer a
7. The default initial value of an external storage class variable is
a) 0
b) 1
c) Garbage value
d) NULL
Answer a
8. The external storage class variables have _______ scope
a) Local
b) Global
c) Block scope
d) No scope
Answer b
9. Which storage class variables are fastest to access?
a) register
b) automatic
c) static
d) external
Answer a
10. What is the output of the following program
#include<stdio.h>
#include<conio.h>
void increment();
int main()
{
increment();
increment();
increment();
getch();
return 0;
}
void increment()
{
staticinti=0;
printf("%d \t",i);
i++;
}
a) 0 0 0
b) 0 1 2
c) 1 1 1
d) 2 2 2
Answer b
#include<stdio.h>
#include<conio.h>
void increment();
int main()
{
increment();
increment();
increment();
getch();
return 0;
}
void increment()
{
inti=0;
printf("%d \t",i);
i++;
}
a) 0 0 0
b) 0 1 2
c) 1 2 3
d) None of these
Answer a
12. What is the output of the following program
#include<stdio.h>
#include<conio.h>
inti;
int main()
{
printf("%d",i);
getch();
return 0;
}
a) 0
b) 1
c) Garbage value
d) external value
Answer a
13. What is the output of the following program
#include<stdio.h>
#include<conio.h>
int main()
{
int a;
printf("%d",a);
getch();
return 0;
}
a) 0
b) Garbage value
c) 1
d) None of these
Answer b
14. The keyword used for declaring a external variable is
a) exter
b) extern
c) ext
d) global
Answer a
15. The syntax for declaring a register variable is
a) register int a;
b) regint a;
c) int register a;
d) intreg a;
Answer a