0% found this document useful (0 votes)
4 views29 pages

C Programming

This document is a course outline for a C Programming paper for BCA students at St. Joseph's College, detailing various units and questions related to programming concepts. It includes multiple-choice questions covering topics such as algorithms, data types, arrays, functions, and structures. Each question is followed by the correct answer, providing a comprehensive review of essential C programming knowledge.

Uploaded by

Matthew Richard
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)
4 views29 pages

C Programming

This document is a course outline for a C Programming paper for BCA students at St. Joseph's College, detailing various units and questions related to programming concepts. It includes multiple-choice questions covering topics such as algorithms, data types, arrays, functions, and structures. Each question is followed by the correct answer, providing a comprehensive review of essential C programming knowledge.

Uploaded by

Matthew Richard
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/ 29

DEPARTMENT OF INFORMATION TECHNOLOGY

St. Joseph’s College (Autonomous)


Tiruchirappalli – 620 002
Course BCA
Sem I Paper Code Units I–V
Title of the
C PROGRAMMING
Paper
Staff Name

UNIT – I
1. In order to solve a problem using a computer it is necessary to evolve
a detailed and precise step by step method of_________.
a) Problem b) Solution
c) procedure d) None of these
Answer: b
2. A computing machine designed to carry out _________ for data
processing thus has the configuration.
a) Algorithm b) Solution
c) Problem d) function
Answer: a
3. If the steps in the algorithm are to be carried out automatically without
_________ intervention the entire algorithm must be stored for
reference.
a) Computer b) human
c) Machine d) All the above
Answer: b
4. Instructions are carried out without any _________.
a) Syntax b) Instruction
c) Mistake d) None of these
Answer: c
5. The algorithm should be precise, concise and ___________.
a) Ambiguous b) In ambiguous
c) Unambiguous d) All the above
Answer: c
6. ___________ with rounded ends are used to indicate START and
STOP.
a) Rectangle b) Circle
c) square d) Irregular shape
Answer: a
7. Parallelograms are used to represent _______________ operations.
a) Processing b) Input and output
c) Start Q Stop
Answer: b
8. The algorithm in a pictorial form called a ___________.
a) Algorithm b) Program
c) Flowchart d) All the above
Answer: c
9. The next step is to express the flowchart in a more precise and concise
notation called a ___________.
a) Algorithm language b) Flowchart language
c) Programming language d) None of these
Answer: c
10. The computer’s processing unit interprets the instructions in the
program, executes them and sends the result to the _______ unit.
a) Input b) Output
c) Processing d) All of the above
Answer: b
11. scanf() can be used for reading__________.
a) double character b) single character
c) multiple characters d) no character
Answer: c
12. A variable which is visible only in the function in which it is defined,
is called____________.
a) static variable b) auto variable
c) external variable d) local variable
Answer: d
13. Determine which of the following is a valid character constant_____.
a) ‘\\’ b) ‘\0’
c) ‘xyz’ d) ‘\052’
Answer: a
14. If a = 5 and b = 7 then the statement p = (a > b) :a ? b_____
a) assigns a value 5 to p b) assigns a value 7 to p
c) assigns a value 8 to p d) gives an error message
Answer: d
15. The format identifier ‘%i’ is also used for _____ data type?
a) Char b) int
c) Float d) Double
Answer: b
16. C language was invented by___________.
a) Abacus b) Charles babage
c) Thomson d) Dennis Ritchie
Answer: d
17. The __________ statement causes immediate exit from the loop
overriding the condition test.
a) Exit b) Break
c) Goto d) None of the above
Answer: b
18. The operators << and >> are_____________.
a) assignment operator b) relational operator
c) logical operator d) bitwise shift operator
Answer: d
19. The C language consists of ____ number of keywords.
a) 32 b) 40
c) 24 d) 56
Answer: a
20. Which of the following is not a valid C variable name?
a) int number; b) float rate;
c) int variable_count; d) int $main;
Answer: d
21. By default a _________number is treated as a double.
a) Positive b) negative
c) Real d) None of the above
Answer: c
22. Which of the following is not a valid variable name declaration?
a) float PI = 3.14; b) double PI = 3.14;
c) int PI = 3.14; d) #define PI 3.14
Answer: d
23. By default a real number is treated as a________.
a) Float b) Double
c) long double d) far double
Answer: b
24. The precedence of arithmetic operators is (from highest to lowest)?
a) %, *, /, +, - b) %, +, /, *, -
c) +, -, %, *, / d) %, +, -, *, /
Answer: a
25. Which of the following declaration is correct?
a) int length; b) char int;
c) int long; d) float double;
Answer: a
26. In which header file is the NULL macro defined?
a) stdio.h b) stddef.h
c) stdio.h and stddef.h d) math.h
Answer: c
27. Which of the following is not an arithmetic operation?
a) a *= 20; b) a /= 30;
c) a %= 40; d) a != 50;
Answer: d
28. What are the different of real data types in C ?
a) float, double b) short int, double, long int
c) float, double, long double d) double, long int, float
Answer: c
29. Which of the following range is a valid long double?
a) 3.4E-4932 to 1.1E+4932 b) 3.4E-4932 to 3.4E+4932
c) 1.1E-4932 to 1.1E+4932 d) 1.7E-4932 to 1.7E+4932
Answer: a
30. Which of the following data type will throw an error on modulus
operation (%)?
a) char b) short
c) Float d) int
Answer: c
UNIT - II
31. In Array, There is one to one correspondence between set of
________ and set of values.
a) variable b) Memory locations
c) indices d) Constants
Answer: c
32. _______refers to the name of variable, function and arrays
a) Tokens b) Symbols
c) Identifier d) Constants
Answer: c
33. What is right way to Initialize array?
a) int num[6] = { 2, 4,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 };
Answer: a
34. A_______ constant is a sequence of character enclosed in double
quotes.
a) Character b) String
c) Pointer d) Float
Answer: b
35. An array elements are always stored in ________ memory locations.
a) sequential b) random
c) Sequential and random d) None of the above
Answer: a
36. Smallest element of an array is called as _______.
a) Lower bound b) range
c) Middle bound d) Upper bound
Answer: a
37. A________ is a data name that may be used to store a data value.
a) Variable b) Function
c) Program d) Types
Answer: a
38. Which of the following is not possible statically in C?
a) Jagged Array b) Rectangular Array
c) Cuboidal Array d) Multidimensional Array
Answer: a
39. A single character can be defined using _________ data type
a) String b) Float
c) Char d) Signed
Answer: c
40. An arithmetic operation involving only real operands is called
_________ arithmetic.
a) Real b) Integer
c) Mixed d) String
Answer: a
41. The maximum number of dimension an array can have in C is___
a) 3 b) 4
c) 5 d) compiler dependent
Answer: d
42. An array name must be chosen according to the same rules used for
naming any other_________.
a) operator b) variable
c) function d) Integer
Answer: b
43. The ________ used to declare an array sometimes is called the
dimensions.
a) script b) subscript
c) scalar d) Expression
Answer: b
44. The dimension used to declare an array must always be a positive
_____ constant.
a) float b) Double
c) integer d) While
Answer: c
45. The function________ is called to input the array.
a) write_array b) read_array
c) Point d) Sort_array
Answer: b
46. A ________declaration tells the compiler about a function's name,
return type, and parameters.
a) function b) operator
c) char d) Loop
Answer: a

47. The default parameter passing mechanism is ______.


a) call by value b) Call by reference
c) Call by value result d) None of these above
Answer: a
48. The keyword used to transfer control from a function back to the
calling function is________.
a) Switch b) Goto
c) go back d) Return
Answer: d
49. Strings are actually one-dimensional array of characters terminated by
a null character__________.
a) '\b' b) '\0'
c) '\t' d) None of these above
Answer: b
50. Which header file should be included to use functions like malloc()
and calloc()?
a) memory.h b) stdlib.h
c) string.h d) dos.h
Answer: b
51. What is the return-type of the function sqrt()
a) Int b) Float
c) Double d) None of these above
Answer: c
52. A function _______is simply the declaration of a function that
specifies function's name, parameters and return type.
a) body b) method
c) prototype d) None of the above
Answer: c
53. A _________ declaration tells the compiler about a function's name,
return type, and parameters.
a) operator b) Function
c) statement d) None of these above
Answer: b
54. A program calls a function, the program control is transferred to the
called _________.
a) Parameter b) Operator
c) function d) Complier error
Answer: c
55. The return statement terminates the execution of a function and
returns a value to the ________.
a) Function b) Character
c) Integer d) calling function
Answer: d
56. The method copies the actual value of an argument into the formal
parameter of the function called__________.
a) Call by value b) Call by reference
c) Method d) Function
Answer: a
57. Which of the following function declaration is illegal?
a) int 1bhk(int); b) int 1bhk(int a);
c) int 2bhk(int*, int []); d) All of the mentioned
Answer: d
58. The value obtained in the function is given back to main by using
________ keyword?
a) Return b) static
c) New d) volatile
Answer: a
59. What is the default return type if it is not specified in function
definition?
a) Void b) int
c) Double d) Short int
Answer: b
60. Global variables are_______.
a) Internal b) External
c) Both (a) and (b) d) None of the above
Answer: b

UNIT – III
61. Structures are used to represent a _______.
a) Struct b) record
c) Typedef d) All of the mentioned
Answer: b
62. If initialization is a part of a structure, then storage class can be____.
a) Automatic b) Register
c) Static d) Anything
Answer: d
63. A structure is a convenient tool for building a group of logically
related ________items.
a) Data b) Control
c) Variable d) None of the above
Answer: a
64. ______is a collection of variables of different types under a single
name.
a) Model b) Field
c) Structure d) None of the above
Answer: c
65. Size of a union is determined by size of the________.
a) First member in the union b) Last member in the union
c) Biggest member in the union d) Sum of the sizes of all members
Answer: c
66. Structure help to organize________ data in a more meaningful way.

a) Complex b) Static
c) Dynamic d) Value
Answer: a
67. The keyword struct declares a structure to hold the details of________
data field.
a) Two b) Three
c) Four d) One
Answer: c
68. How will you free the allocated memory?
a) remove(var-name); b) free(var-name);
c) delete(var-name); d) dalloc(var-name);
Answer: b
69. What is the similarity between a structure, union and enumeration?
a) All of them let you define b) All of them let you define new
new values data types
c) All of them let you define d) All of them let you define new
new pointers structures
Answer: b
70. Which of the following operation is illegal in structures?
a) Typecasting of structure b) Pointer to a variable of same
structure
c) Dynamic allocation of d) All the above
memory for structure
Answer: a
71. If initialization is a part of a structure, then storage class can be
___________.
a) Automatic b) Register
c) Static d) anything
Answer: d
72. Which of the following are themselves a collection of different data
types?
a) structure b) string
c) File d) None of above
Answer: a
73. ________data type can be derived by enum.
a) User-defined b) predefined
c) typedef d) All of the above
Answer: a
74. Which operator connects the structure name to its member name?
a) & b) .
c) @ d) %
Answer: b
75. Which of the following cannot be a structure member?
a) Another structure b) Function
c) Array d) All the above
Answer: b
76. Members of a union are accessed as________________.
a) union-name.member b) union-pointer->member
c) Both a & b d) None of the mentioned
Answer: c
77. A structure variable can be passed to the function as an ______as a
normal variable.
a) operator b) constant
c) argument d) None of these
Answer: c
78. The memory address of a structure variable is passed to function while
passing it by__________.
a) reference b) value
c) address d) None of the above
Answer: a
79. _______variables can be created in similar manner as structure
variables.
a) constant b) operator
c) Union d) None of the above
Answer: c
80. A union is a special data type available in C that allows to store
different data types in the same memory___________.
a) allocation b) location
c) Address d) None of above
Answer: b
81. The ______occupied by a union will be large enough to hold the
largest member of the union.
a) address b) memory
c) Variable d) None of above
Answer: b
82. The member access ____ is coded as a period between the union
variable name and the union member.
a) variable b) code
c) operator d) None of the above
Answer: c
83. A ______ can be passed to any function from main function or from
any sub function.
a) structure b) union
c) variable d) constant
Answer: a
84. Which of the following return-type cannot be used for a function in C?
a) Char* b) struct
c) void d) None of the above
Answer: b
85. Which of the following operation is illegal in structures?
a) Typecasting of structure b) Pointer to a variable of same
structure
c) Dynamic allocation d) All of the mentioned
Answer: a
86. User-defined data type can be derived by___________.
a) struct b) enum
c) typedef d) All of the mentioned
Answer: d
87. Which of the following cannot be a structure member?
a) Another structure b) function
c) array d) None of the above
Answer: b
88. Which of the following is not allowed?
a) Arrays of bit fields b) Pointers to bit fields
c) Functions returning bit fields d) None of the above
Answer: d
89. Bit fields can only be declared as part of a structure.
a) false b) true
c) nothing d) varies
Answer: b
90. Which of the following data types are accepted while declaring bit-
fields?
a) Char b) float
c) double d) None of these
Answer: a
UNIT - IV
91. Memory addresses within a computer are referred as ________.
a) Variable b) Character
c) Pointer d) Real
Answer: c
92. Pointer is a special kind of variable which is used to store _________
of the variable.
a) Data type b) Address
c) Value d) Variable name
Answer: b
93. Pointer variable is preceded by _________ sign, in declaration.
a) & b) *
c) ^ d) %
Answer: b
94. _________ sign is preceded before the variable name to fetch the
address of the variable.
a) & b) *
c) % d) ^
Answer: a
95. ___________ operator is used to initialize the variable after declaring
the pointer variable.
a) Assignment b) Logical
c) Relational d) Increment
Answer: a
96. Address stored in the pointer is of _______ data type.

a) Float b) Integer
c) Array d) Character
Answer: b
97. Which of the following way is valid for declaring a pointer variable?
a) Datatypepointername>*; b) Datatype<pointername>&;
c) Datatype *<pointername>; d) Datatype&<pointername>;
Answer: c
98. Incrementing a pointer to an integer data will cause its value to be
incremented by ______.
a) 4 b) 2
c) 1 d) 8
Answer: b
99. -> is called a ________ operator.
a) Arrow b) Minus
c) Directional d) None of these
Answer: a
100. _________ can be stored in a pointer variable.
a) Address b) Value
c) Pointer d) None of these
Answer: a
101. In pointers, * is called as ________operator.
a) Address b) Indirectional
c) Value d) Pointer
Answer: b
102. Before using the pointer variable, it should be_________.
a) Declared b) Initialized
c) Declared and initialized d) None of these
Answer: c
103. What type of statement int **p; is ?
a) Illegal b) Is legal but meaningless
c) Is syntactically and d) None of these
semantically correct
statement
Answer: c
104. A pointer is a _________.
a) A keyword used to create b) A variable that stores address
variables of other variable
c) A variable that stores address d) All of the above
of an instruction
Answer: b
105. Which of the following way is the correct way to declare a float
pointer?
a) Float *ptr; b) Float ptr;
c) *float ptr; d) None of these
Answer: a
106. #include <stdio.h>
void main()
{
int a[3] = {1, 2, 3};
int *p = a;
printf("%p\t%p", p, a);
} Give the output.
a) Same address is printed. b) Different address is printed.
c) Compile time error d) None of the above
Answer: a
107. int main()
{
int m=25;
int *p=&m;
printf(“%d”,*p);
getch();
}
Give the output.
a) 25 b) Address of the variable
c) Compilation error d) None of these
Answer: a
108. int main()
{
int *p, m=25;
p=&m;
printf(“%d”,*p);
getch();
} Give the output.
a) 25 b) Address of m
c) Compilation error d) None of these
Answer: a
109. To declare a 3 dimension array using pointers, which of the following
is the correct syntax:
a) char *a[][]; b) char **a[];
c) char ***a; d) All of the mentioned
Answer: a
110. int main()
{
int x=10,y=20,sum;
int *z1=&x;
int *z2=&y;
printf(“%d”,*z1>*z2);
getch();
} Give the output.
a) 20 b) 1
c) 10 d) 0
Answer: d
111. #include <stdio.h>
void main()
{
char *a[10] = {"hi", "hello", "how"};
printf("%d\n", sizeof(a[1]));
}
a) 6 b) 4
c) 5 d) 3
Answer: b
112. #include <stdio.h>
int main()
{
char *a = {"p", "r", "o", "g", "r", "a", "m"};
printf("%s", a);
} Give the output.
a) Output will be program b) Output will be p
c) No output d) Compile time error
Answer: b
113. An array of strings can be initialized by _______.
a) char *a={“hi”, “hello”}; b) char *a={“hi”, “hellos”};
c) char *b= ”hello”; d) All the above
Answer: d
114. Can two different huge pointers contain two different addresses but
refer to the same location in memory?
a) Yes b) No
c) Can’t say d) None
Answer: b
115. Which of the following keyword or function to de-allocate memory?
a) Free b) Delete
c) Clear d) remove
Answer: a
116. Which of the following gives the value stored at the address pointed to
by pointer a?
a) a; b) val(a);
c) *a; d) &a;
Answer: c
117. Which of the following gives the memory address of a variable
pointed to by pointer a?
a) a; b) *a;
c) &a; d) Address(a);
Answer: a
118. Which of the following keyword to allocate memory in C?
a) New b) Malloc
c) Create d) Value
Answer: b
119. What is size of generic pointer in C?
a) 1 b) 2
c) 3 d) 4
Answer: b
120. Comment on the following declaration.
int *ptr,p;
a) ptr is a pointer to integer, p is b) ptr and p, both are pointers to
not. integer
c) ptr is a pointer to integer, p d) Ptr and p both are not pointers
may or may not be. to integer
Answer: a
UNIT - V
121. _________ is a string of characters that make a valid name for the
operating system.
a) File name b) File size
c) File structure d) None of these
Answer: a
122. Data structure of a file is defined as _______ in the library of standard
i/o function definition.
a) Fopen b) STRUCT
c) FILE d) INPUT
Answer: a)
123. When an existing file is opened using _____ mode, the contents of the
file are deleted.
a) R b) w
c) O d) c
Answer: b
124. The function name __________ sets the position to the beginning of
the file.
a) Forward b) Rewind
c) Fseek d) None ofthese
Answer: b
125. __________ specifies the number of position to be moved from the
location specified by position.
a) Inset b) Offset
c) Byset d) Position
Answer: b
126. In file management, when an operation is success, ________function
return a zero.
a) Ftel b) Frewind
c) Fseek d) Free
Answer: c
127. In file management, to create a file ____________.
a) allocate the space in file b) make an entry for new file in
system directory
c) Both a and b d) None of the these
Answer: c
128. The ______ mode of operation tells that the existing file is opened to
the beginning for both reading and writing.
a) w+ b) r+
c) a+ d) r
Answer: b)
129. _____ is used to read a character from a file that has been opened in
read mode.
a) Putc b) getw
c) Putw d) getc
Answer: d
130. The function name _____ creates a new file.
a) fclose() b) getc()
c) fopen() d) putc()
Answer: c
131. The function name________ writes a set of data values to a file.
a) fprintf( ) b) fscanf()
c) putc() d) fseek()
Answer: a
132. The general form of getw() is_______.
a) getw(integer); b) getw(integer,fp);
c) getw(fp); d) none of these
Answer: c
133. The ______ function is used to test for an end of file condition.
a) Feof b) ferror
c) Ftel d) All of the above
Answer: a
134. The general form of fseek() is _______________.
a) fseek(fileptr,offset,position); b) fseek(fileptr,offset);
c) fseek(offset,position); d) fseek(file_ptr,position);
Answer: a
135. The function fopen("filename","r")returns___________.
a) A value 0 or 1 depending on b) A pointer to FILE filename,if it
whether the file could be exits
opened or not.
c) A pointer to a new file after d) None of the above
creating it.
Answer: b
136. The function fprintf()works like printf(), but operates on________.
a) Strder b) stdin
c) Stdio d) None of these
Answer: b
137. _________ modifies the size of previously allocated space.
a) Malloc b) Realloc
c) Free d) calloc
Answer: b
138. The program instructions and global and static variables are stored in
a region known as __________.
a) Stack b) Heap
c) Permanent storage area d) Both a and c
Answer: c
139. The function ______is used to dynamically allocate memory to arrays.
a) Calloc() b) Malloc
c) Realloc d) Both a and b
Answer: a
140. Stacks are referred as _____.
a) Local variables b) Global variables
c) Permanent variables d) Both a and c
Answer: a
141. What does the following statement mean?
fseek(fp,0L,0)
a) fp is a file pointer b) position the read-write-head at
the start of the file
c) position the read-write-head d) None of these
at the end of the file
Answer: b
142. If a file is opened in w+ mode then ______________.
a) after write operation reading b) Reading is possible
is possible without closing
and re-opening
c) Writing is possible d) All of the above
Answer: d
143. The contents of a file will be lost if it is opened in _____________.
a) a mode b) w mode
c) a+ mode d) w+mode
Answer: d
144. In the following statement,
fprintf(fpt,"%n",i),the variable fpt is a/an
a) Integer variable b) Arbitrarily assigned value
c) Pointer to a file d) special kind of a variable called
file
Answer: c
145. What does the following statement mean?
ptr=realloc(ptr,newsize);
a) Allocates new size b) Returns a pointer to the
firstbyte of the new memory
block
c) Both a and b d) None of these
Answer: c
146. What do the 'c' and 'v' in argv stands for?
a) ‘c’ means argument control b) ‘c’ means argument control and
and ‘v’ means argument ‘v’ means argument vertex
vector
c) ‘c’ means argument count d) ‘c’ means argument control and
and ‘v’ means argument ‘v’ means argument visibility
vector
Answer: c
147. Which of the following statements are false about the below code?
int main(int ac, char*av[])
a) ac contains count addresses b) av[] contains addresses of
of arguments supplied at arguments supplied at a
command-line command line
c) In place of ac and av, argc d) The variables ac and av are
and argv should be used. always local to main()
Answer: c
148. What does fp point to in the following program?
#include<stdio.h>
int main()
{
FILE *fp;
fp=fopen("trial", "r");
return 0;
}
a) The first character in the file b) A structure which contains a
char pointer which points to the
first character of a file.
c) The name of the file d) The last character of the file
Answer: b
149. Which of the following operations can be performed on the file
"NOTES.TXT" using the below code?
FILE *fp;
fp = fopen("NOTES.TXT", "r+");
a) Reading b) Writing
c) Appending d) Read and write
Answer: d
150. _________ is used to seek absolute from the end of the file.
a) SEEK_END b) SEEK_SET
c) SEEK_CUR d) NONE OF THESE
Answer: a

********************

You might also like