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 D

Paper Details
  • Subject: Programming Skills Using C
  • Subject Code: 204
  • Set: D
  • 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: Student Record Sorting

Max Marks: 10

Consider a structure as follow:

struct stud_info {
int rno;
char sname[30];
int marks;
};

Write a C program that accept details of N-students and display student's details in descending order on marks.

1. Data Structure & Selection Sort

Implement student records and sort them by performance using a simple sorting algorithm.

Hint

Accept $N$ from the user, then use an array of struct stud_info. Use a nested loop (Bubble or Selection sort) to rearrange the array based on the marks field.

View Solution & Output
#include <stdio.h>
#include <string.h>

struct stud_info {
int rno;
char sname[30];
int marks;
};

int main() {
int n, i, j;
struct stud_info s[100], temp;

printf("Enter number of students: ");
scanf("%d", &n);

// [1] Accept Input
for(i = 0; i < n; i++) {
printf("\nEnter Details for Student %d:\n", i+1);
printf("Roll No: "); scanf("%d", &s[i].rno);
printf("Name: "); scanf("%s", s[i].sname);
printf("Marks: "); scanf("%d", &s[i].marks);
}

// [2] Sort Descending (Bubble Sort)
for(i = 0; i < n - 1; i++) {
for(j = 0; j < n - i - 1; j++) {
if(s[j].marks < s[j+1].marks) {
temp = s[j];
s[j] = s[j+1];
s[j+1] = temp;
}
}
}

// [3] Display Output
printf("\nStudents Sorted by Marks (Descending):\n");
printf("RNo\tName\tMarks\n");
for(i = 0; i < n; i++) {
printf("%d\t%s\t%d\n", s[i].rno, s[i].sname, s[i].marks);
}

return 0;
}

Step-by-Step Explanation:

  1. Initialization: Define the stud_info structure and accept the total number of students N from the user.
  2. Logic Flow: Read details into an array of structures and apply the Bubble Sort algorithm to sort them based on marks in descending order.
  3. Completion: Display the sorted student records in a tabular format showing Roll No, Name, and Marks.

Q2: Python String Menu

Max Marks: 10

Write a Python program that accept a line of text from user and perform following operations on it.

  1. Toggle case
  2. Title case
  3. Sentence case
  4. Exit Note: Menu will be repeated until user select Exit option.

1. Multi-Case String Transformation

Implement a command-line interface to manipulate text formatting.

Hint

Use input().swapcase() for toggle, input().title() for title case, and input().capitalize() for sentence case. Wrap everything in a while True loop.

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

while True:
print("\n--- STRING MENU ---")
print("1. Toggle Case")
print("2. Title Case")
print("3. Sentence Case")
print("4. Exit")

choice = input("Enter your choice (1-4): ")

if choice == '1':
print("Result:", text.swapcase())
elif choice == '2':
print("Result:", text.title())
elif choice == '3':
print("Result:", text.capitalize())
elif choice == '4':
print("Exiting...")
break
else:
print("Invalid Choice!")

Step-by-Step Explanation:

  1. Initialization: Accept a string input and enter a while True loop to display a repeating menu.
  2. Logic Flow: Based on user choice, apply swapcase(), title(), or capitalize() methods to transform the text.
  3. Completion: Print the transformed result or exit the loop if the user chooses the exit option.

Q3: Viva Preparation

Max Marks: 5

Potential Viva Questions
  1. Q: How do you swap two structures in C?
    • A: By using a temporary structure variable of the same type and performing three assignment operations.
  2. Q: Difference between title() and capitalize() in Python?
    • A: title() capitalizes the first letter of EVERY word; capitalize() only the first letter of the ENTIRE string.
  3. Q: What is a nested loop?
    • A: A loop inside another loop, often used for processing 2D arrays or sorting.
  4. Q: What is Bubble Sort?
    • A: A simple sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order.
  5. Q: How can you check if a string consists only of digits in Python?
    • A: Use the .isdigit() method.
  6. Q: What is struct padding in C?
    • A: It is the addition of empty bytes by the compiler between structure members to align them with memory boundaries for faster access.
Common Pitfalls
  • Infinite Loops: Ensure the Python menu has a clear break condition for choice 4.
  • Buffer Overflow: In C, char sname[30] can only hold 29 characters + null. Use scanf("%29s", ...) for safety.

Quick Navigation

SetLink
Set ASolutions
Set BSolutions
Set CSolutions
Set DCurrent Page
Set ESolutions
Set FSolutions

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