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 E

Paper Details
  • Subject: Programming Skills Using C
  • Subject Code: 204
  • Set: E
  • 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: Maximum of Three Numbers

Max Marks: 10

Write a C program to create a user defined function max() which accept 3- numbers and return maximum number from them.

1. Comparison Logic

Develop the max() function using conditional statements.

Hint

Use if-else if-else logic to compare the three variables. Return the variable that holds the largest value.

View Solution & Output
#include <stdio.h>

// [1] User-defined function to find max
int max(int a, int b, int c) {
if(a >= b && a >= c)
return a;
else if(b >= c)
return b;
else
return c;
}

int main() {
int x, y, z;
printf("Enter three numbers: ");
scanf("%d %d %d", &x, &y, &z);

// [2] Call function and display
printf("Maximum Number is: %d\n", max(x, y, z));

return 0;
}

Step-by-Step Explanation:

  1. Initialization: Define a max() UDF that takes three integer parameters and uses conditional checks to compare them.
  2. Logic Flow: In main(), read three numbers and pass them as arguments to the max() function.
  3. Completion: The function returns the largest value, which is then displayed to the user.

Q2: Python Pandas CSV Analytics

Max Marks: 10

Create a DataFrame from CSV file which contains following values: Book_no, Book_name, Price, Author. Perform following operations on it:

  1. Print the values of book name.
  2. Display book name and author.
  3. Display the details of book named 'Let us C'.
  4. Display the details of book at location 3rd.

1. CSV Loading & Selection

Process a book catalog using Pandas indexing and filtering.

Hint

Use pd.read_csv() to load. Use df['col'] or df[['col1', 'col2']] for selection, and df.iloc[2] for the 3rd location (index starts at 0).

View Solution & Output
import pandas as pd

# [0] Create sample CSV for demonstration
data = {
'Book_no': [1, 2, 3, 4],
'Book_name': ['Python Pro', 'Let us C', 'Java Hub', 'C++ Expert'],
'Price': [500, 350, 450, 600],
'Author': ['Guido', 'Y. Kanetkar', 'James', 'Bjarne']
}
pd.DataFrame(data).to_csv('books.csv', index=False)

# [1] Load DataFrame
df = pd.read_csv('books.csv')

# [i] Print values of book name
print("--- Book Names ---")
print(df['Book_name'])

# [ii] Display book name and author
print("\n--- Name and Author ---")
print(df[['Book_name', 'Author']])

# [iii] Details of 'Let us C'
print("\n--- Details of 'Let us C' ---")
print(df[df['Book_name'] == 'Let us C'])

# [iv] Details of book at 3rd location
print("\n--- 3rd Book Record ---")
print(df.iloc[2])

Step-by-Step Explanation:

  1. Initialization: Create a sample book CSV file and load it into a pandas DataFrame using read_csv().
  2. Logic Flow: Select specific columns, filter rows by book name, and access specific records using integer-based indexing with iloc.
  3. Completion: Print the specific filtered and indexed data as requested by the operations.

Q3: Viva Preparation

Max Marks: 5

Potential Viva Questions
  1. Q: Can a function return more than one value in C?
    • A: Directly, no. But we can use pointers or structures to return multiple data points indirectly.
  2. Q: What is the difference between loc and iloc in Pandas?
    • A: loc is label-based (uses row/column names); iloc is integer-position based (uses numeric indices).
  3. Q: How does read_csv() handle headers by default?
    • A: It assumes the first row of the CSV file contains the column names.
  4. Q: What is a ternary operator in C? Can we use it for finding max of 3?
    • A: It is a shorthand for if-else (condition ? expr1 : expr2). Yes: max = (a>b) ? (a>c?a:c) : (b>c?b:c).
  5. Q: How do you filter a DataFrame for multiple conditions?
    • A: Using bitwise operators & (AND) or | (OR), e.g., df[(df['Price'] > 400) & (df['Author'] == 'Guido')].
  6. Q: What is df.info() used for?
    • A: It provides a summary of the DataFrame including column names, data types, and non-null counts.
Common Pitfalls
  • Indexing Bias: Remember that iloc[3] gives the 4th row. For the 3rd row, use iloc[2].
  • File Not Found: Ensure books.csv exists in the script's directory before calling read_csv.

Quick Navigation

SetLink
Set ASolutions
Set BSolutions
Set CSolutions
Set DSolutions
Set ECurrent Page
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