SOL Computer Programming MS Winter 2024 25
SOL Computer Programming MS Winter 2024 25
Evaluation Scheme:
Only dividing by 4 : 2 marks
Complete flow chart : 5 marks
Explicit Casting:
○ Performed manually by the programmer using the cast operator (type) to force a
conversion.
○ Gives the programmer full control over how and when the conversion happens.
Evaluation Scheme:
Both Explanation and example given: 2 Marks
Either explanation or example: 1 Mark
Incorrect/ not answered: 0 Mark
Practical Example:
When to Choose a for Loop
Scenario: You know you need to iterate exactly 10 times to print numbers from 1 to 10.
// 'for' loop is clearer here since we know exactly how many times we iterate.
for(int i = 1; i <= 10; i++) {
printf("%d\n", i);
}
In the first case, a for loop makes it clear we’re iterating a fixed number of times. In the second, a
while loop is appropriate because the loop continues based on a condition rather than a fixed count.
Evaluation Scheme:
Both comparison and practical example given: 4Marks
Comparison and example of either one given: 3 Marks
Either comparison or example given: 2 Marks
Partially correct comparison or example: 1 Mark
Incorrect or not answered: 0 Mark
Evaluation Scheme:
Completely correct: 6 Marks
diamond printing correct: 4 Marks
Even odd check: 2 Marks
If code correct but slight syntax error or some statement missing: 2 Marks
Incorrect or not answered: 0 Mark
Part B (Maximum Marks: 30)
Q. No. Question
1. (a) next = first + second + third ;
first = second ;
second = third;
third = next ;
Evaluation Scheme:
Correct statement: 1 Mark each
Correct statement, but the order is wrong: ½ Mark
Evaluation Scheme:
Correct answer: 1 Mark each
Correct answer, but written in binary form: ½ Mark each
Correct answer is written directly in decimal form: ½ Mark each
Correct answer, but no computational step: ½ Mark each
2. (a) A flowchart is a visual representation of the sequence of steps in a process or algorithm. It uses
different symbols to illustrate the flow of control, making it easier to understand complex logic.
[i] Clarity – It helps programmers and non-programmers understand the logic of an algorithm.
[ii] Debugging – Identifies logical errors before coding.
[iii]Efficiency – Helps in planning and organizing code structure before implementation.
[iv] Communication – Provides a clear way to explain an algorithm to others.
Evaluation Scheme:
Flowchart Explanation: 2 Marks
Correct Flowchart: 5 Marks
Pseudo Code / C Program (as an alternative to the Flowchart): 2 Marks
(b) #include <stdio.h>
int main() {
char str[100]; // Array to store input string
int length = 0;
Evaluation Scheme:
Reading String: 2 Marks
Finding Substring: 6 Marks
o If the approach is correct but contains errors in implementation: 2 Marks
o If the substring search is implemented but has minor logical errors: 4 Marks
o If the substring is correctly found and implemented efficiently: 6 Marks