Computer Science Objective Questions and Answers: Programming in C
Review structured MCQ sets for Computer Science Programming in C. Built according to official NCERT guidelines, these downloadable questions support daily revision and core concept reinforcement.
Download Programming in C MCQs with Answers
Navigate directly to the 50 objective questions for Programming in C using the digital viewer below. Each practice set includes verified answer keys, allowing students to instantly cross-check their work and identify areas requiring further revision.
This page has 25 multiple choice questions on C++ arrays, strings and structures, covering declaration and indexing, null-terminated strings and string.h functions, two-dimensional arrays, structure members, assignment, arrays of structures and typedef. Each question has a hidden answer with a short explanation.
(a) Array
(b) int
(c) char
(d) float
Show Answer & Explanation
Answer: (a) Array
Explanation:
1. int, char and float are primitive types built into the compiler.
2. An array bundles many values of one type under a single name, so it is a structured type.
Teacher's Note:
1. Primitive types hold one value; structured types bundle several.
2. Arrays and structures are the two structured types in this chapter.
(a) 1
(b) -1
(c) It depends on the array size
(d) 0
Show Answer & Explanation
Answer: (d) 0
Explanation:
1. Array indexing in C++ always starts from zero.
2. This does not change with the length of the array.
Teacher's Note:
1. An array of n elements has indices 0 to n-1.
2. Counting from 1 is a common beginner error.
(a) myArr[5]
(b) myArr[6]
(c) myArr[4]
(d) myArr[1]
Show Answer & Explanation
Answer: (c) myArr[4]
Explanation:
1. Valid indices run from 0 to 4 for five elements.
2. myArr[5] would be the sixth element, which is outside the array.
Teacher's Note:
1. Last valid index = size - 1.
2. Out-of-range access is not caught by the compiler.
(a) 4 elements
(b) 5 elements
(c) 6 elements
(d) It gives a compile-time error
Show Answer & Explanation
Answer: (b) 5 elements
Explanation:
1. When the brackets are empty the compiler counts the initial values.
2. Five values are given, so the array has five int elements.
Teacher's Note:
1. An initializer list lets you leave the size blank.
2. The size is taken from the number of values.
(a) a variable read at run time
(b) a constant value
(c) a negative number
(d) always a floating point value
Show Answer & Explanation
Answer: (b) a constant value
Explanation:
1. Ordinary arrays use non-dynamic memory, so the size is fixed before the program runs.
2. A constant (or a #define name) therefore has to be used.
Teacher's Note:
1. Variable length needs dynamic memory.
2. Use a constant or #define for the size.
(a) Undetermined (unpredictable) values
(b) All zeros
(c) All ones
(d) The index of each element
Show Answer & Explanation
Answer: (a) Undetermined (unpredictable) values
Explanation:
1. Local arrays are not given default values.
2. Only global and static arrays are filled with zeros automatically.
Teacher's Note:
1. Local means garbage until you store something.
2. Global and static arrays start with zeros.
(a) A compilation error is always reported
(b) The element is created automatically
(c) The program uses myArr[0] instead
(d) No compilation error, but it may cause a run-time error
Show Answer & Explanation
Answer: (d) No compilation error, but it may cause a run-time error
Explanation:
1. C++ does not check array bounds when compiling.
2. Reading or writing outside the array may crash the program or corrupt data.
Teacher's Note:
1. Bounds are the programmer's responsibility.
2. Compiles fine, fails at run time.
(a) 5
(b) 4
(c) 6
(d) 7
Show Answer & Explanation
Answer: (c) 6
Explanation:
1. The five letters H, e, l, l, o take five elements.
2. A string literal also gets the null character '\0' at the end, giving a sixth element.
Teacher's Note:
1. Size of a string array = letters + 1.
2. The extra one is the null character.
(a) '\n'
(b) '\t'
(c) '\0' (null character)
(d) '.'
Show Answer & Explanation
Answer: (c) '\0' (null character)
Explanation:
1. Functions that handle strings stop scanning when they meet the null character.
2. '\0' is a backslash followed by zero.
Teacher's Note:
1. Null terminator = '\0'.
2. It is not the same as '0'.
(a) 7
(b) 6
(c) 5
(d) 0
Show Answer & Explanation
Answer: (b) 6
Explanation:
1. strlen counts the characters of the string.
2. Hurray has six letters, and the null character is not counted.
Teacher's Note:
1. strlen ignores the null terminator.
2. It lives in string.h.
(a) Copies the content of mstr into ystr
(b) Copies ystr into mstr
(c) Compares ystr and mstr
(d) Joins mstr at the end of ystr
Show Answer & Explanation
Answer: (a) Copies the content of mstr into ystr
Explanation:
1. The second argument is the source and the first is the destination.
2. So the text of mstr is copied into ystr.
Teacher's Note:
1. strcpy(destination, source).
2. Remember: the first one receives.
(a) Kamal
(b) lamak
(c) Kamal0
(d) lamaK
Show Answer & Explanation
Answer: (d) lamaK
Explanation:
1. strrev reverses the characters in the same array.
2. Reading Kamal backwards gives lamaK, with case unchanged.
Teacher's Note:
1. strrev changes the original string.
2. Capital letter K moves to the end.
(a) s1 is bigger than s2
(b) s2 is bigger than s1
(c) either string is empty
(d) both strings are equal
Show Answer & Explanation
Answer: (d) both strings are equal
Explanation:
1. strcmp returns zero for equal strings, a positive value if the first is bigger and a negative value if the second is bigger.
2. The comparison follows the ASCII order.
Teacher's Note:
1. 0 means equal.
2. The comparison is case sensitive.
(a) strcmp()
(b) strcpy()
(c) strcmpi()
(d) strlen()
Show Answer & Explanation
Answer: (c) strcmpi()
Explanation:
1. strcmp is case sensitive.
2. The version strcmpi performs a case insensitive comparison.
Teacher's Note:
1. Think of the i in strcmpi as 'ignore case'.
2. strcmpi("Kamal", "kamal") gives 0.
(a) 8
(b) 15
(c) 35
(d) 5
Show Answer & Explanation
Answer: (b) 15
Explanation:
1. It has 3 rows and 5 columns.
2. The total is 3 x 5 = 15 elements.
Teacher's Note:
1. Multiply the dimensions.
2. Indices are twoDArr[0][0] to twoDArr[2][4].
(a) twoDArr[1][3]
(b) twoDArr[2][4]
(c) twoDArr[3][1]
(d) twoDArr[4][2]
Show Answer & Explanation
Answer: (a) twoDArr[1][3]
Explanation:
1. Indices begin at zero, so the second row has index 1.
2. The fourth column has index 3.
Teacher's Note:
1. Position number minus one gives the index.
2. Row index first, column index second.
(a) The address of the array
(b) A complete copy of the whole block of memory
(c) Only the first element's value
(d) Only the size of the array
Show Answer & Explanation
Answer: (a) The address of the array
Explanation:
1. C++ cannot pass a whole block of memory by value.
2. The address is passed, which is faster and more efficient.
Teacher's Note:
1. Arrays travel by address.
2. The parameter is written like int arg[].
(a) structure
(b) record
(c) typedef
(d) struct
Show Answer & Explanation
Answer: (d) struct
Explanation:
1. A structure is created with the keyword struct followed by its name and a block of data members.
2. typedef is only used to give another name to a datatype.
Teacher's Note:
1. struct Name { members };
2. End the block with a semicolon.
(a) &
(b) ::
(c) . (dot, the component operator)
(d) ->>
Show Answer & Explanation
Answer: (c) . (dot, the component operator)
Explanation:
1. The dot operator connects the variable name with its member, as in w1.age.
2. It is called the component operator.
Teacher's Note:
1. variable.member
2. Do not confuse it with the scope operator.
(a) One declared outside main()
(b) One that gives a value to a data member inside the structure, such as age = 16;
(c) One that has a char array as a member
(d) One that ends with a variable list such as W1, W2
Show Answer & Explanation
Answer: (b) One that gives a value to a data member inside the structure, such as age = 16;
Explanation:
1. No data member may be initialized inside the structure declaration.
2. Values are given later, to the variables of the structure.
Teacher's Note:
1. Declare first, initialize later.
2. Structure declaration just describes the layout.
(a) It copies all members
(b) It is invalid because the structures are of different types
(c) It copies only the matching name
(d) It works only if the members are int
Show Answer & Explanation
Answer: (b) It is invalid because the structures are of different types
Explanation:
1. Assignment between structure variables requires the same structure type.
2. Equal member types and order do not make two different structures compatible.
Teacher's Note:
1. Same type name is required.
2. Same members are not enough.
(a) Worker W[20];
(b) Worker(20) W;
(c) struct W[20];
(d) W Worker[20]
Show Answer & Explanation
Answer: (a) Worker W[20];
Explanation:
1. The syntax is structure_name array_name[size];.
2. Each of the 20 elements is a complete Worker with all its members.
Teacher's Note:
1. Type first, then name, then size.
2. W[0] to W[19] are the elements.
(a) passed by value only
(b) declared as a typedef
(c) declared static
(d) passed by reference, as in Worker &w
Show Answer & Explanation
Answer: (d) passed by reference, as in Worker &w
Explanation:
1. A reference parameter refers to the actual argument.
2. Otherwise the function works on a copy and must return the modified structure.
Teacher's Note:
1. & in the parameter means reference.
2. Alternatively return the structure.
(a) A single character
(b) An array of 30 strings
(c) A character array of size 30
(d) An integer variable
Show Answer & Explanation
Answer: (c) A character array of size 30
Explanation:
1. typedef gives the new name string to the type 'array of 30 chars'.
2. So name is the same as char name[30].
Teacher's Note:
1. typedef only gives another name.
2. No new memory type is created.
(a) 12071
(b) 12160
(c) 12206
(d) 135
Show Answer & Explanation
Answer: (c) 12206
Explanation:
1. The loop adds the five elements into result.
2. 16 + 2 + 77 + 40 + 12071 = 12206.
Teacher's Note:
1. Add them carefully.
2. The printed value is the total.
Free study material for Computer Science
Multiple Choice Questions (MCQs) for Computer Science Programming in C
Download Multiple Choice Questions: Programming in C ( Computer Science)
Review structured objective questions for Computer Science Programming in C. Built according to official NCERT guidelines, these MCQ sets support daily revision and core concept reinforcement.
Concept Clarification for Programming in C
Cross-reference your completed choices with comprehensive NCERT solutions for Computer Science to ensure absolute clarity across all sub-topics in this chapter.
Additional Study Resources for Computer Science
Explore our broader library of printable assignments, chapter notes, and mock tests designed to support continuous revision and secure higher marks in NCERT assessments.
FAQs
You can get most exhaustive Arrays and Structures Chapter 04 Structured Data Types Arrays and Structures MCQs Set 01 for free on StudiesToday.com. These MCQs for Computer Science are updated for the 2026-27 academic session as per examination standards.
Yes, our Arrays and Structures Chapter 04 Structured Data Types Arrays and Structures MCQs Set 01 include the latest type of questions, such as Assertion-Reasoning and Case-based MCQs. 50% of the paper is now competency-based.
By solving our Arrays and Structures Chapter 04 Structured Data Types Arrays and Structures MCQs Set 01, students can improve their accuracy and speed which is important as objective questions provide a chance to secure 100% marks in the Computer Science.
Yes, Computer Science MCQs for have answer key and brief explanations to help students understand logic behind the correct option as its important for 2026 competency-focused exams.
Yes, you can also access online interactive tests for Arrays and Structures Chapter 04 Structured Data Types Arrays and Structures MCQs Set 01 on StudiesToday.com as they provide instant answers and score to help you track your progress in Computer Science.