0% found this document useful (0 votes)
15 views11 pages

PPS Mid 2 QB Objective

This document is a question bank for the II Mid Examination in Programming for Problem Solving (PPS) for B.Tech-I Year students. It contains objective questions covering various topics such as arrays, strings, pointers, and memory allocation in C programming. Each question is followed by multiple-choice answers, with the correct answer indicated for each question.

Uploaded by

anishakadabur
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
0% found this document useful (0 votes)
15 views11 pages

PPS Mid 2 QB Objective

This document is a question bank for the II Mid Examination in Programming for Problem Solving (PPS) for B.Tech-I Year students. It contains objective questions covering various topics such as arrays, strings, pointers, and memory allocation in C programming. Each question is followed by multiple-choice answers, with the correct answer indicated for each question.

Uploaded by

anishakadabur
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/ 11

B.

Tech-I YEAR– I SEM (MR24)


II Mid Examination Objective Question Bank
Subject: Programming for Problem Solving (PPS) Subject code: D0501
Branch: Common to All

S.No Question Answer


Module 3
1 subscript operator in an array is represented with_______________ B
A) {} B) [] C) () D)None
2 ________is a fixed size sequenced collection of elements of the same data A
type
A)Array B)Structure C)Identifier D)none
3 An Array can be initialized either at compile time or at _____ A
A)Run time B)Static time C)Run time & static time D)None
4 In C,by default the first subscript of array is _________ B
A)One B)Zero C)Two D)None
5 What will be the output of the program? C
#include<stdio.h>
int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];//2
j = a[1]++;//2
m = a[i];
printf("%d, %d ,%d", i, j, m);
return 0;
}
A)2, 1, 15 B)1, 2, 5 C)2, 2, 15 D)2, 3, 20

6 What is right way to Initialize array? A


A)int num[6] = { 2, 4, 12, 5, 45, 5 }; B)int n{} = { 2, 4, 12, 5, 45, 5 };
C)int n{6} = { 2, 4, 12 }; D)int n(6) = { 2, 4, 12, 5, 45, 5 };

7 An array elements are always stored in ________ memory locations A


A)Sequential B)Random C)Sequential and Random D)None of the above
8 What is the maximum number of dimensions an array in C may have? D
A)2 B)8 C)20 D)Theoretically no limit

9 Size of the array need not be specified, when D


A)Initialization is a part of definition B)It is a declaration C)It is a formal
parameter d)All of these
10 Which of the following correctly accesses the seventh element stored in arr, A
an array with 100 elements?
A)Arr[6] B)Arr[7] C)Arr{8} D)Arr{6}
11 int a[5] = {1,2,3}What is the value of a[2]? C
A) 1 B) 2 C)3 D)0

12 What is meaning of following declaration? C


int arr[20];
A)Array of size 20 that can have integer addresses B)Array of Size 19
C)Integer Array of size 20 D)None of these

13 Below is an example of : int RollNum[30][4]; B


A)1-D Array B) 2-D Array C)3-D Array D)4-D Array
14 If we have declared an array described below –int arr[6];then which of the B
following array element is considered as last array element ?
A)arr[4] B)arr[5] C)arr[3] D) arr[0]
15 Array is ______ data type in C Programming language. B
A)Basic data type B) Derived data type C)User defined data type D)
none
16 One Dimensional array is declared as B
A)Type arr_name[row-size][col-size]; B)Type arr_name[ ]; C)Type
arr_name[ ][ ][ ]; D)Type arr_name[ ][ ];
17 Correct format to initialize the 1-D array B
A)int a[10]=[1,2]; B)int a[3]={1,2,3}; C)Char a[2]=qs; D)None

18 Which of the following correctly declares an array? A


A)int anarray[10]; B)int anarray; C)anarray{10}; D)array
anarray[10];
19 The array elements are represented by B
A)Index values B) Subscripted variables C)Array name D)Size of array
20 When should an array be used? B
A)When we need to hold variable constants B)when there is a need to use
many variables of the same type C)When we need to hold data of same type
D)None
21 One dimensional array is also known as_______ A
A)Single subscripted variable B)Double subscripted variable C) C.Three
subscripted variable D)None
22 An array is a ____________sequenced collection of elements of the same B
data type
A)Variable size B)Fixed size C)Dynamic size D) None
23 The process of allocating memory at compile time is known as __________ B
A)Dynamic memory allocation B)Static memory allocation
C)Both A & B D) None
24 Syntax of three dimensional array A
A)Int a[ ][ ][ ] B)Char a[] C) Float a{} D) Int aP{}{}
25 When we declare an array ,we need to specify __________ D
A)Name B)Type C)Size D)All
Module-4

26 ASCII code for a-z ranges from C


A)0-26 B)35-81 C)97-122 D)None of these
27 If str[ ]=”Welcome to world of programming”,then,SUBSTRING(str,15,5)= A
A)world B)programming c)welcome D)None of these
28 Which of the following function is more appropriate for reading in a multi- B
word string?
A)scanf() B)gets() C) printf()
D)puts()
29 String concatenation means is _________________. A
A)Combining two strings
B) Extracting a substring out of a string
C)Copying a substring out of a string
D)Merging two strings
30 strcat() is defined in which header file? C
A)ctype.h B)stdio.h C)string.h D)math.h

31 s1=”Hi”, s2=”Hello”, s3=”Bye”. How can we concatenate three strings? B


A)strcat(s1,s2,s3) B)strcat(s1,(strcat(s2,s3)) C)strcpy(s1,strcat(s2,s3))
D)None of these
32 What will strcmp() function do? B
A)compares the first n characters of the object
B) compares the string
C) undefined function
D) copies the string

33 What is a String in C Language.? B


A) String is a new Data Type in C
B) String is an array of Characters with null character as the last element of
array.
C) String is an array of Characters with null character as the first element of
array
D) String is an array of Integers with 0 as the last element of array.

34 What is the Format specifier used to print a String or Character array in C C


Printf or Scanf function.?
A) %c B) %C C) %s D) %w

35 What is the output of C Program with Strings.? B


int main()
{
char ary[]="Engineering";
printf("%s",ary);
return 0;}
A)E B)Engineering C) Engineer D)None of these
36 What is the output of C Program with arrays.? D
int main()
{
char str[]={"C","A","T","\0"};
printf("%s",str);
return 0;
}
A) CB) CATC) CAT\0D) Compiler error
37 In C, string constants are the constants that are enclosed in a pair of _______ A
A)double quote B)parenthesis C)single quote D)bracket
38 Which of the following function sets first n characters of a string to a given B
character?
A)strinit() B)strnset() C) strset() D)strcset()
39 If the two strings are identical, then strcmp() function returns C
A)-1 B)1 C)0 D)Yes

40 Which of the following statements are correct ? B


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

41 A pointer variable contains as its value the __________of the another B


variable
A)Data value B)Address C)Data type
D)None
42 The __________operator is used with a pointer to de-reference the address A
contained in the pointer
A)* B)& C)$ D)#
43 Find the error in the following statements ____________. D
A)int x=10 B)int *y; C)int **x=&m D)None
44 If a variable is a pointer to a structure, then which of the following operator D
is used to access data members of the structure through the pointer variable?
A). B)* C)& D).->
45 A pointer is________. C
A)A keyword used to create variables B)variable that stores address of
an instruction C)A variable that stores address of other variable
D)All of the above

46 The operator used to get value at address stored in a pointer variable B


is_______
A). B)* C)& D)||
47 What is the output ? C
#include<stdio.h>
void main()
{
int i=3, *j, k;
j = &i;
printf("%d\n", i**j*i+*j);
getch();
}
A)9 B)27 C)30 D)0
48 Which of the statements is correct about the program? C

#include<stdio.h>
main()
{
int i=10;
int *j=&i;
return 0;
}
A)j and i are pointers to an int
B)i is a pointer to an int and stores address of j
C)j is a pointer to an int and stores address of i
D j is a pointer to a pointer to an int and stores address of i

49 Consider the 32 bit compiler. We need to store address of integer variable to B


integer pointer. What will be the size of integer pointer ?
A)6 Bytes B)4 Bytes C)2 Bytes D)10 Bytes

50 Pointer is a __________data type that contains memory address as its value. B


A)Primary B)Derived C)User-defined D)array

51 Address stored in the pointer variable is of type __________. B


A)Character B)Integer C)Float D)array
52 In order to fetch the address of the variable we write preceding _____sign A
before variable name
A)& B) , C)* D)%
53 What is the output of this C code? C

void main()
{
int *ptr, a = 10;
ptr = &a;
*ptr += 1;
printf("%d,%d/n", *ptr, a);
}
A)10,10 B)10,11 C)11,11
D)11,10
54 Which is comment on the following? A
Constant *ptr;
A)You cannot change the value pointed by ptr
B)You cannot change the pointer ptr itself C)Both (a) and (b)
D)You can change the pointer as well as the value pointed by it
55 What is the output of this C code? A

int x = 0;
void main()
{
int *ptr = &x;
x++;
printf("%d\n", x);
printf("%d\n ", *ptr);
}
A)11 B)10 C)1 D)0
56 What is the output of this C code? C
void main()
{
int x = 0;
int *ptr = &5;
printf("%d\n", *ptr);
}
A)5 B)Address of 5 C)Compile time error
D)None
57 What is the output of this C code? C
void main()
{
int x;
int *ptr = &x;
printf("%d\n", *ptr);
getch();
}
A)0 B)1 C)Garbage value D)Address of x
58 Which of the following is the correct way of declaring a float pointer? B
A)float ptr B)float *ptr C)*float ptr D)None
59 Which header file should be included to use functions like malloc() and B
calloc()?
A)memory.h B)stdlib.h C)stdio.h D)dos.h
60 What function should be used to free the memory allocated by calloc() ? C
A)dealloc() B)realloc() C)free() D)malloc()

61 Specify the 2 library functions to dynamically allocate memory? C


A)memory() and malloc() B)alloc() and calloc()
C)malloc() and calloc() D) free() and freealloc()
62 The following function can be used for dynamic deallocation of memory A
is____.
A)free() B)delete() C)remove() D)destroy()

63 The syntax of malloc()is_________________. D


A)int *malloc(size,int); B)void malloc(); C)void malloc(int); D)int
*malloc(sizeof(int));

64 Single block of memory is allocated by____________. D


A)realloc() B)calloc() C)free() D)malloc()
65 multiple blocks of memory is allocated by____________. B
A)realloc() B)calloc() C)free() D)malloc()
66 C compiler provides a number of built-in __________. A
A)library functions B)user defined functions C)derived functions
D)dynamic memory functions
67 C preprocessor is conceptually the first step during compilation. A
A)TRUE B)FALSE C)depends on standard D)depends on system
68 The number of arguments used in malloc() is__________________. B
A)0 B)1 C)2 D)3

69 The number of arguments used in calloc () is________________. C


A)0 B)1 C)2 D)3
70 The number of arguments used in realloc() is_________________. C
A)0 B)1 C)2 D)3
71 The pointers can be used to achieve________. B
A)call by function B)call by reference C)call by name D)call by procedure

72 The ampersand operator returns__________. A


A)the address of its operand B)L value C)both A& B D)R value

73 Identify the invalid pointer operator__________. C


A)& B)* C)>> D)none of the above
74 A pointer value refers to___________. D
A)any ordinary variable B)float value C)integer constant D)any valid
address in memory
75 Identify the invalid expression from the following. D
A)&275 B)*(*a*b) C)&(*a+b) D)all of the above

MODULE 5
76 Memory for a structure is allocated at the time of B
A)structure definition B)structure variable declaration
C)structure declaration D)function declaration
77 What is the similarity between a structure, union and enumeration B
A)To define new values B)To define new data types
C)To define new pointers D)To define new structures
78 Which operator connects the structure variable to its member name? C
A). B)-> C) Both A and B D)None
79 Which of the following cannot be a structure member? A
A)Function B)Another structure C) Array D) None
80 The size of a union is determined by size of _____________? C
A) The first member in the union B)The sum of the sizes of all member
C)The biggest member in the union D. The last member in the union
81 What would be the size of the following union declaration? C
union utemp
{
double a;
int b[10];
char c;
}u;
A)4 B)8 C)40 D)80
82 Members of a union are accessed as_____________. C
A)Unionvariable.member B) Unionpointervariable->member
C)bothA&B D) None
83 Which of the following share a similarity in syntax? B
1)union 2)structure 3)arrays 4)pointers
A)3&4 B)1&2 C)1&3 D)1,3&4

84 Which of the following operation is illegal in structures? A


A) Typecasting of structure B) Pointer to a variable of same structure C)
Dynamic allocation of memory for structure D) All
85 Which of the following is the correct syntax for declaring a structure? A
A)Struct tag-name
{
datatype mem1;
datatype mem2;
};
B)Struct;
{
datatype 1
data type 2
}
C)Struct
[datatype1
datatype2]
D)struct:
{
data type 1
data type 2
}
86 C allows nesting of structures till which level? C
A)13 B)14 C)15 D)16
87 The uninitialized character data type of a structure contains which of the A
following default values___________
A)Garbage B) Zero C) ‘/0’ D) None
88 __________ is the keyword which is used to declare a structures C
A) Auto B) continue C) Struct D) structure
89 ___________is the operator returns the address of a variable. D
A)Size of B) Ternary C) ++ D) &
90 Is Array index checking is done by the C compiler? B
A) Yes B) No C) at runtime D)None of the above
91 What will be the size of a union variable? D
union item
{
int a;
float b;
char c;
}item1;
A)1 B)2 C)4 D)8
92 The array index starts with___ and ends with ____? A
A) 0, size-1 B) 0, size C) 1, size-1 D) 1, size
93 __________ is the keyword which is used to declare a structures C
A)Auto B) continue C) Struct D) Structure
94 ___________ is the operator that tells us the size of a structure. A
A)Sizeof B)Teranary C) ++ D) &&

95 The uninitialized integer data type of a structure contains which of the A


following default values
A) GarbageB) Zero C) /0 D) One
96 In the following declaration, what will be the size of a structure variable? D
struct item
{
int a;
float b;
char c;
}item1;
A)1 B)2 C)4 D)7
97 ________ is derived data type A
A)Struct B)enum C). typedef D)All
98 What is the output of this code? D
void main()
{
struct student
{
int no;
char name[20];
};
struct student s;
s.no=8;
printf(“%d”,s.no);
}
A)Nothing B)Compile time error C)Runtime error D)8
99 Number of bytes in memory taken by the below structure B
is______________.
struct s
{
int a;
char c;
};
A)4 B)5 C)Depends on Compiler D)None
100 Which of the following data types are not accepted while declaring bit- D
fields
A)Char B)float C).double D)None

101 Which of the following is allowed A


A)bit fields within structures B)Pointers to bit fields C)Functions
returning bit fields D)None
102 Bit fields can only be declared as part of a structure______________ B
A)FALSE B)TRUE C)Varies D)Nothing
103 Structure points to itself is known as________. C
A)Dynamic B)Static C)Self-referential structure D)Both A&B
104 Structure elements are also known as______________. B
A)pointer of structure B)Members of structure C)Variables of structure
D)Array of structure
105 Which keyword is used to declare union? A
A)Union B)Struct C)int D)static

106 If the file name is enclosed in double quotation marks? A


A)The pre-processor treats it as a user-defined file
B) The pre-processor treats it as a system-defined file
C)Both a & b D)none of the above
107 If the file name is enclosed in angle brackets? B
A)The preprocessor treats it as a user-defined file
B) The preprocessor treats it as a system-defined file
C)Both a & b D)none of the above
108 The first and second arguments of fopen( ) are_______________. A
A) A character string containing the name of the file & the second argument
is the mode.
B)A character string containing the name of the user & the second argument
is the mode
C)A character string containing file pointer & the second argument is the
mode.
D)None of the above
109 For binary files, ___ must be appended to the mode string. B
A)nothing B)"b" C)"binary" D)"01"
110 If there is any error while opening a file, fopen() will return? C
A)Nothing B)EOF C)NULL D)Depends on compiler
111 Which is true about getc? getc returns___________. C
A)The next character from the stream referred to by file pointer
B)EOF for end of file error C)Both a & b D)Nothing.
112 When a C program is started, O.S environment is responsible for opening D
file and providing__________ pointers for that file?
A)standard input
B)standard output
C)standard error D)all of the above
113 FILE is of type is ______ B
A)int type B)char * type C)struct type
D)None of the mentioned
114 What is the meant by ‘a’ in the following operation? B
fp = fopen(“Random.txt”, “a”);
A)attach B)append C)apprehend D)add
115 Which of the following mode argument is used to read &write? D
A)Rw B)t C)w D)r+
116 Which of the following fopen statements are illegal? D
A)fp = fopen(“abc.txt”, “r”); B) fp = fopen(“/home/user1/abc.txt”, “w”);
C)fp = fopen(“abc”, “w”); D) None of the mentioned
117 FILE reserved word is________________. B
A)One of the basic datatypes in c
B) It is a type name defined in stdio.h
C)Both a &b D) None of the mentioned
118 Binary search algorithm cannot be applied to ________________. A
A)sorted linked list B)sorted binary trees C)sorted linear array D)sorted
pointer array
119 According to ANSI specification which is the correct way of declaring main A
when it receives command-line arguments?
A)main(int argc, char *argv[]) B)main(argc,argv) int argc; char *argv[];
C)main() {int argc; char *argv[]; } D)None of the above
120 Which of the following is TRUE about argv? A
A)It is an array of character pointers B)It is a pointer to an array of character
pointers C)It is an array of strings D) None of the above
121 int main(int ac, char *av[]){….............} C
A)ac contains count of arguments supplied at command-line
B)av[] contains addresses of arguments supplied at a command line
C)In place of ac and av, argc and argv should be used.
D) The variables ac and av are always local to main()
122 int main(int argc, char *argv[]), here the argc represents__________ A
A)Argument count B) Argument copy C)Argument name
D) None of the above
123 argv[0] in the command line argument represent_____________. C
A)Argument count B) Argument copy
C)name of the program D) None of the above
124 main() function can accept __________arguments. B
A)0 or 2 B)0,1,2 C)3 D)4
125 Which function gives the current position of the file? C
A)fseek() B)fsetpos() C)ftell() D)rewind()

Course Coordinator Dean- I Yr.

You might also like