Solved Paper: Computational Thinking using C
Q1. Attempt all questions
(a) Define the term Testing. Explain its types.
Testing is the process of evaluating a system or its components with the intent to find
whether it satisfies the specified requirements or not. It helps identify errors, gaps,
or missing requirements.
Types of Testing:
1. Unit Testing
2. Integration Testing
3. System Testing
4. Acceptance Testing
(b) What is a variable? Define its initialization and declaration with the help of an example.
A variable is a storage location in programming with a specific data type that holds data.
Example in C:
int a; // Declaration
a = 10; // Initialization
int b = 20; // Declaration and Initialization
(c) Write a C program to find the factorial of a number that is input by the user.
C Program:
#include <stdio.h>
int main() {
int n, i;
unsigned long long factorial = 1;
printf("Enter an integer: ");
scanf("%d", &n);
if (n < 0)
printf("Error! Factorial of a negative number doesn't exist.");
else {
for (i = 1; i <= n; ++i) {
factorial *= i;
printf("Factorial of %d = %llu", n, factorial);
return 0;
(d) What is an algorithm and flowchart? Explain symbols used in a flowchart.
An algorithm is a step-by-step procedure to solve a problem. Flowchart is a graphical
representation.
Common symbols:
1. Oval: Start/End
2. Rectangle: Process
3. Parallelogram: Input/Output
4. Diamond: Decision
5. Arrow: Flow of control.
Q2. Attempt any three questions
(a) Define the term array and its types with example.
An array is a collection of elements stored in contiguous memory locations.
(b) A supermarket offers a discount of 10% if purchase exceeds 1000.
C Program:
#include <stdio.h>
int main() {
float amount, finalAmount;
printf("Enter the total amount: ");
scanf("%f", &amount);
if (amount > 1000) {
finalAmount = amount - (amount * 0.10);
} else {
finalAmount = amount;
printf("The final amount is: %.2f
", finalAmount);
return 0;
(c) Difference between while and do-while loop.
While: Condition is checked before execution.
Do-while: Executes first then checks condition.
(d) What is a pointer? Define the use of * and & operators with an example.
A pointer stores the address of another variable.
Example:
int a = 10;
int *p = &a; // Pointer stores the address of a
printf("Value: %d", *p); // Dereferencing.
Q3. Attempt any two questions
(a) Analyse the role of Debugging in programming.
Debugging is the process of identifying and removing errors in a program.
(b) Write a C program to insert elements into two matrices and store their sum.
C Program:
#include <stdio.h>
int main() {
int mat1[2][2], mat2[2][2], sum[2][2];
printf("Enter elements for the first matrix:
");
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
scanf("%d", &mat1[i][j]);
}
}
printf("Enter elements for the second matrix:
");
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
scanf("%d", &mat2[i][j]);
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
sum[i][j] = mat1[i][j] + mat2[i][j];
printf("Sum of matrices:
");
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
printf("%d ", sum[i][j]);
printf("
");
return 0;
}
(c) Define the term function in C programming.
A function is a block of code designed to perform a specific task.
Example: void greet() { printf("Hello"); }