Skip to main content
Unlisted page
This page is unlisted. Search engines will not index it, and only users having a direct link can access it.

VNSGU BCA Sem 2: Programming Skills Using C (204) Practical Solutions - April 2025 Set F

Paper Details
  • Subject: Programming Skills Using C
  • Subject Code: 204
  • Set: F
  • Semester: 2
  • Month/Year: April 2025
  • Max Marks: 25
  • Time Recommendation: 45 Minutes
  • Paper: View Paper | Download PDF

Questions & Solutions

All questions are compulsory

Q1: Matrix Addition

Max Marks: 10

Write a C program to perform matrix addition of two 3x3 matrices.

1. Matrix Input & Addition Logic

Sum the corresponding elements of two 3x3 grids.

Hint

Define three 2D arrays: a[3][3], b[3][3], and sum[3][3]. Add elements at the same position: sum[i][j] = a[i][j] + b[i][j].

View Solution & Output
#include <stdio.h>

int main() {
int a[3][3], b[3][3], sum[3][3], i, j;

printf("Enter elements for Matrix A:\n");
for(i=0; i<3; i++)
for(j=0; j<3; j++)
scanf("%d", &a[i][j]);

printf("Enter elements for Matrix B:\n");
for(i=0; i<3; i++)
for(j=0; j<3; j++)
scanf("%d", &b[i][j]);

// [1] Addition Logic
for(i=0; i<3; i++) {
for(j=0; j<3; j++) {
sum[i][j] = a[i][j] + b[i][j];
}
}

printf("\nResultant Matrix (A+B):\n");
for(i=0; i<3; i++) {
for(j=0; j<3; j++) {
printf("%d\t", sum[i][j]);
}
printf("\n");
}

return 0;
}

Step-by-Step Explanation:

  1. Initialization: Declare three 3x3 integer arrays for Matrix A, Matrix B, and their sum.
  2. Logic Flow: Read elements for both matrices using nested loops, then calculate sum[i][j] = a[i][j] + b[i][j].
  3. Completion: Print the final resultant matrix representing the sum of the two input matrices.

Q2: Python Unique String Generator

Max Marks: 10

Write a Python program that accept a line of text (which consist of multiple words) from input device. Remove duplicate characters from it and make a line of text unique.

1. Character Deduplication

Extract and display unique characters from a string while preserving their first appearance.

Hint

Use a loop to iterate through the string and append characters to a new list/string only if they haven't been seen before. Alternatively, use a set for speed (though sets don't preserve order).

View Solution & Output
# [1] Accept input
line = input("Enter a line of text: ")
unique_chars = ""

# [2] Remove duplicates preserving order
for char in line:
if char not in unique_chars:
unique_chars += char

print("Original Text:", line)
print("Unique Characters Text:", unique_chars)

Step-by-Step Explanation:

  1. Initialization: Accept a line of text and initialize an empty string unique_chars to store unique characters.
  2. Logic Flow: Iterate through each character of the input and append it to unique_chars only if it is not already present.
  3. Completion: Display the original text and the new string containing only unique characters in their original order.

Q3: Viva Preparation

Max Marks: 5

Potential Viva Questions
  1. Q: What are the requirements for Matrix Addition?
    • A: Both matrices must have the same dimensions (e.g., both 3x3).
  2. Q: How can we remove duplicates using a Set in Python?
    • A: "".join(set(line)) - however, this will likely lose the original order of characters.
  3. Q: What is the time complexity of the unique character script?
    • A: $O(N^2)$ in the string implementation (since in check is linear), or $O(N)$ if using a Set for the seen check.
  4. Q: How do you declare a 2D array in C?
    • A: Using data_type array_name[rows][cols]; e.g., int a[3][3];.
  5. Q: What is an f-string in Python?
    • A: It is a literal string prefixed with 'f' that allows embedding expressions inside curly braces {} for easy formatting.
  6. Q: What happens if you try to add matrices of different sizes?
    • A: Mathematically it is undefined, and in a program it would lead to logical errors or out-of-bounds array access.
Common Pitfalls
  • Space Handling: Spaces are also characters. If the question implies removing duplicate letters but keeping spaces, you need an extra if char != ' ' check.
  • C Array Bounds: In C, always ensure loops stay within the defined dimensions (0 to 2 for size 3).

Quick Navigation

SetLink
Set ASolutions
Set BSolutions
Set CSolutions
Set DSolutions
Set ESolutions
Set FCurrent Page

Last Updated: April 2026

📍 Visit Us

🏫 VD Computer Tuition Surat

VD Computer Tuition
📍 Address
2/66 Faram Street, Rustompura
Surat395002, Gujarat, India
📞 Phone / WhatsApp
+91 84604 41384
🌐 Website

Computer Classes & Tuition — Areas We Serve in Surat

AdajanAlthanAmroliAthwaAthwalinesBhagalBhatarBhestanCanal RoadChowkCitylightDumasGaurav PathGhod Dod RoadHaziraJahangirpuraKamrejKapodraKatargamLimbayatMagdallaMajura GateMota VarachhaNanpuraNew CitylightOlpadPalPandesaraParle PointPiplodPunaRanderRing RoadRustampuraSachinSalabatpuraSarthanaSosyo CircleUdhnaVarachhaVed RoadVesuVIP Road
📞 Call Sir💬 WhatsApp Sir