Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 21

Topic: Question on Call by Value and call by reference

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

3. Which operator is used for getting address of a variable

a. *

b. &

c. !

d. @

Answer: B

4. Which operator is used for getting in value from a address

a. *

b. &
c. !

d. @

Answer: A

5. If a=5, b=10, a=&b then what is the output of printf(“%d”,*a);

a. 5

b. 10

c. &a

d. &b

Answer: B

6. If a=5, b=10, a=&b then what is the output of printf(“%d”,*(&b));

a. 5

b. 10

c. &a

d. none of the above

Answer: B

7. In case of pass by reference

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

c. The variables x and y are passed to the function addition

d. None of the above are valid.

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

3.What is the use of getchar()?


a) To write a character on standard output
b) To read a character from standard input.
c) Nothing
d) Both a & b

4.How many characters readed by getchar() from standard input

a. 1
b. 2
c. 3
d. 0

5. What is the default return-type of getchar()?


a) char
b) int
C. char*
D. Reading character doesn’t require a return-type

6. What is the default return-type of putchar()?


a) char
b) int
C. void
D. float

7. What is the use of putch()?


a) To write a alphanumeric character on standard output
b) To read a alphanumeric character from standard input.
c) Nothing
d) Both a & b

8.What is the use of getch()?


a) To write a alphanumeric character on standard output
b) To read a alphanumeric character from standard input.
c) Nothing
d) Both a & b

9. gets() is used for?


a) To read the string from standard input
b) To write a character on standard output
c) Nothing
d) Both a & b

10. puts() is used for?


a) To read the string from standard input
b) To write a string on standard output
c) Nothing
d) Both a & b
Topic: String manipulation functions and library functions of
string Searching and sorting of string, Character arithmetic
1. Which of the following function sets first n characters of a string to a given character?

A. strinit() B. strnset()

C. strset() D. strcset()

Answer: B

2. If the two strings are identical, then strcmp() function returns

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?

A. strcmp(s1, s2) returns a number less than 0 if s1>s2

B. strcmp(s1, s2) returns a number greater than 0 if s1<s2

C. strcmp(s1, s2) returns 0 if s1==s2

D. strcmp(s1, s2) returns 1 if s1==s2

Answer: C

7. Which of the following statements are correct ?

1: A string is a collection of characters terminated by '\0'.

2: The format specifier %s is used to print a string.

3: The length of the string can be obtained by strlen().

4: The pointer CANNOT work on string.

A.1, 2 B.1, 2, 3

C.2, 4 D.3, 4

Answer B

8. What will be the output of the program ?

#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

9. What will be the output of the program ?

#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(){

char arr[11]="The African Queen";

printf("%s",arr);

a. The African Queen

b. The

c. The African

d. Compilation Error

Answer: D

12. What is the output of the following program?

#include<stdio.h>

void main()
{

char str1[] = "Placement Yogi";

char str2[] = "Placement Yogi";

if(str1 == str2)

printf("\n Equal");

else

printf("\nUnequal");

A.Equal

B. Unequal

Compilation Error: string cannot be compared using ==


C.
operator

D. None of the Above

Answer: B

13. What is the output of the following program?

#include<stdio.h>

void main()

char ch = 'A';

printf("%d %d", sizeof(ch), sizeof('A'));

A. 1 1

B. 1 4

C. 4 4

D. None of the above

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

15.Which of the following statements about strings is false?

a. Strings are declared as character arrays.

b. As long as they are identically declared, including their length, one string may be
assigned to another.

c. Strings may be declared as a character pointer.

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

2. Which one of the following is correct declaration for array


a. Int a [10]
b. Int a[]
c. Int 10[a]
d. None

Answer: A

3. In multi-subscripted arrays what will be the output for expression


Printf(“%d”, a[1][2]);
a. It will display 1st row and 2nd column
b. It will display 2nd row and 2nd column
c. It will display 2nd row and 3rd column
d. None of these

Answer: C

4. Unspecified elements in array must set to


a. NULL
b. 0
c. \0
d. Both a and c

Answer: B

5. Which one of the following is an application of array


a. It stores element of different data type
b. It stores elements of same data type
c. Both a and b
d. None

Answer: B

6. What will be the output for given expression


Int a[5] = {2,3,4};
Printf (“%d%d%d%”,a[0],a[2],a[4]);
a. 2,4,3
b. 2,2,2
c. 2,4,0
d. 2,4,4

Answer: C

7. Array can be used for sorting elements


a. Yes
b. No
c. May be
d. None

Answer: A

8. Find out which error present in program snippet


int l, j, a[3][3];
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
Scanf(“%d”,a[i][j]);
}
}
a. Syntax error
b. Logical error
c. Application error
d. None of these

Answer: A

9. Do array used for maintaining multiple variable names using same name
a. No
b. Yes
c. Both
d. None

Answer: B

10. While initializing 2D array which dimension is mandatory to mentioned


a. Row
b. Column
c. Both a and b
d. None

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

12. Starting address of array is known as


a. Local address
b. Global address
c. Base address
d. None

Answer: C

13. Which one of the following is incorrect declaration of 2D array


a. int a[][5]
b. int a[5][]
c. int a[4][3]
d. Both a and c

Answer: B

14. Which one of the following is example of 2D array


a. Distance [D]
b. Distance, Height [D,H]
c. Distance, Height, Roll [D,H,R]
d. None

Answer: B

15. Find out which error present in program snippet


int i, j, a[3][3];
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
Scanf(“%d”,&a[i][j]);
}
}
1. Syntax error
2. Logical error
3. Application error
4. None of these

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

Q3. Arrays are best data structures


a. for relatively permanent collections of data
b. for the size of the structure and the data in the structure are constantly changing
c. for both of above situation
d. for none of above situation

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

Q5.The elements of an array are stored successively in memory cells because


a. by this way computer can keep track only the address of the first element and the addresses of
other elements can be calculated
b. the architecture of computer memory does not allow arrays to store other than serially
c. both of above
d. none of above
Answer: a

Q6.The Worst case occur in linear search algorithm when


a. Item is somewhere in the middle of the array
b. Item is second element in the array
c. Item is the first element in the array
d. Item is the last element in the array or is not there at all
Answer: d

Q7. The Average case occur in linear search algorithm


a. When Item is somewhere in the middle of the array
b. When Item is not in the array at all
c. When Item is the last element in the array
d. When Item is the last element in the array or is not there at all

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

Q10. Binary search algorithm can not be applied to


a. sorted linked list
b. sorted binary trees
c. sorted linear array
d. pointer array

Answer: a

Q11. Which of the following sorting algorithm is of divide-and-conquer type?


a. Bubble sort
b. Insertion sort
c. Quick sort
d. All of above

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

11. 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()
{
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

You might also like