MyCollegeLab Documentation & Transparency

BCA Practical Programs – C, C++, Python Lab Programs with Output

Complete semester-wise collection of BCA practical programs with working code, expected outputs, and instant online execution.

Last Updated:November 2026
•
Read Time:6 min read
•
Verified for College Computer Labs
BCA Lab Guide

BCA Practical Programs — Run Online Without Installation

The Bachelor of Computer Applications (BCA) syllabus across major Indian universities covers core programming fundamentals in C, Object-Oriented Programming (OOP) in C++, and high-level scripting in Python across semesters 1 through 4 and beyond. Students are regularly required to prepare practical lab records, verify algorithmic outputs, and appear for practical viva examinations.

Setting up and configuring local toolchains, Turbo C emulators, or modern IDEs on locked-down college lab computers can be slow and frustrating. MyCollegeLab enables BCA students to run, inspect, and test these programs directly in the browser with full interactive standard input (stdin) support, Turbo C compatibility stubs, and zero setup.

Semester 1 & 2 — C Fundamentals

Master control structures, iterative loops, 1D/2D arrays, functions, pointers, and string manipulations essential for first-year practicals.

Semester 3 & 4 — C++, OOP & Data Structures

Classes, objects, constructors, function overloading, inheritance, and linear data structure implementations like stacks and queues.

Semester 5 & 6 — Python, Database & Web

Advanced list operations, dictionary lookups, structured file handling, and scripting techniques for final-year project labs.

Run Online — No Compiler Setup

Instant GCC, G++, and Python 3 cloud execution sandbox with full standard input support. Compatible with desktop, tablet, and mobile browsers.

C Language

BCA Semester 1-2: C Programming Practical Programs

These programs are commonly asked in BCA first and second semester C language lab practicals.

Program 1: Fibonacci Series

Generates the Fibonacci series up to N terms using an iterative loop.

#include <stdio.h>
int main() {
    int n, t1 = 0, t2 = 1, next;
    printf("Enter number of terms: ");
    scanf("%d", &n);
    printf("Fibonacci: ");
    for (int i = 1; i <= n; i++) {
        printf("%d ", t1);
        next = t1 + t2;
        t1 = t2;
        t2 = next;
    }
    return 0;
}
Expected Output:Enter number of terms: 7
Fibonacci: 0 1 1 2 3 5 8

Program 2: Prime Number Check

Checks whether an input integer is prime by testing factors up to the square root of N.

#include <stdio.h>
int main() {
    int n, isPrime = 1;
    printf("Enter a number: ");
    scanf("%d", &n);
    if (n < 2) isPrime = 0;
    for (int i = 2; i * i <= n; i++)
        if (n % i == 0) { isPrime = 0; break; }
    printf("%d is %s\n", n, isPrime ? "Prime" : "Not Prime");
    return 0;
}
Expected Output:Enter a number: 17
17 is Prime

Program 3: Star Pattern

Prints a right-angled triangular star pattern using nested for loops.

#include <stdio.h>
int main() {
    int n;
    printf("Enter rows: ");
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= i; j++)
            printf("* ");
        printf("\n");
    }
    return 0;
}
Expected Output:Enter rows: 4
*
* *
* * *
* * * *

Program 4: Reverse a Number

Extracts digits using modulo division to reverse an integer value.

#include <stdio.h>
int main() {
    int n, rev = 0, digit;
    printf("Enter a number: ");
    scanf("%d", &n);
    while (n != 0) {
        digit = n % 10;
        rev = rev * 10 + digit;
        n /= 10;
    }
    printf("Reversed: %d\n", rev);
    return 0;
}
Expected Output:Enter a number: 12345
Reversed: 54321
C++ Language

BCA Semester 3-4: C++ OOP Practical Programs

BCA semesters 3 and 4 focus on Object-Oriented Programming (OOP) concepts including data encapsulation, classes, inheritance, and method polymorphism.

Program 1: Class and Object (Rectangle Area)

Encapsulates length and breadth in a Rectangle class with member functions.

#include <iostream>
using namespace std;
class Rectangle {
    float length, breadth;
public:
    void input() {
        cout << "Enter length and breadth: ";
        cin >> length >> breadth;
    }
    void area() {
        cout << "Area = " << length * breadth << endl;
    }
};
int main() {
    Rectangle r;
    r.input();
    r.area();
    return 0;
}
Expected Output:Enter length and breadth: 5 4
Area = 20

Program 2: Inheritance & Virtual Functions

Demonstrates base-class pointer polymorphism using virtual functions and derived classes.

#include <iostream>
using namespace std;
class Shape {
public:
    virtual void draw() { cout << "Drawing shape" << endl; }
};
class Circle : public Shape {
public:
    void draw() override { cout << "Drawing circle" << endl; }
};
class Square : public Shape {
public:
    void draw() override { cout << "Drawing square" << endl; }
};
int main() {
    Shape* s1 = new Circle();
    Shape* s2 = new Square();
    s1->draw();
    s2->draw();
    return 0;
}
Expected Output:Drawing circle
Drawing square

Program 3: Function Overloading

Demonstrates compile-time polymorphism by declaring multiple versions of the add function.

#include <iostream>
using namespace std;
int add(int a, int b) { return a + b; }
float add(float a, float b) { return a + b; }
int add(int a, int b, int c) { return a + b + c; }
int main() {
    cout << add(3, 4) << endl;
    cout << add(2.5f, 3.7f) << endl;
    cout << add(1, 2, 3) << endl;
    return 0;
}
Expected Output:7
6.2
6
Python Language

BCA Semester 5-6: Python Practical Programs

Senior BCA semesters cover data manipulation with lists, dictionaries, and persistent disk file handling.

Program 1: List Operations

Takes dynamic numeric inputs into a list and computes sorted ordering, aggregate sum, and min/max values.

numbers = []
n = int(input("How many numbers? "))
for _ in range(n):
    numbers.append(int(input()))
print("Original:", numbers)
print("Sorted:", sorted(numbers))
print("Sum:", sum(numbers))
print("Max:", max(numbers), "Min:", min(numbers))
Expected Output:How many numbers? 4
15
3
8
22
Original: [15, 3, 8, 22]
Sorted: [3, 8, 15, 22]
Sum: 48
Max: 22 Min: 3

Program 2: Dictionary (Student Records)

Populates student marks in a dictionary and sorts students in descending rank order.

students = {}
n = int(input("Number of students: "))
for _ in range(n):
    name = input("Name: ")
    marks = int(input("Marks: "))
    students[name] = marks
for name, marks in sorted(students.items(), key=lambda x: x[1], reverse=True):
    print(f"{name}: {marks}")
Expected Output:Number of students: 3
Bob: 92
Alice: 85
Charlie: 78

Program 3: File Handling

Writes structured records to a text file and reads them back line-by-line using Python context managers.

# Write to file
with open("students.txt", "w") as f:
    f.write("Alice,85\n")
    f.write("Bob,92\n")
    f.write("Charlie,78\n")
# Read from file
print("Student Records:")
with open("students.txt", "r") as f:
    for line in f:
        name, marks = line.strip().split(",")
        print(f"  {name}: {marks}")
Expected Output:Student Records:
  Alice: 85
  Bob: 92
  Charlie: 78
Frequently Asked Questions

Frequently Asked Questions

Are these programs from IGNOU / MDU / MAKAUT BCA syllabus?

These cover common BCA practical topics taught across most Indian universities including IGNOU, MDU, MAKAUT, IPU, Pune University, Bangalore University, and AKTU. The core algorithms and language syntax conform strictly to standard university curricula.

Can I copy these programs for my practical file?

Yes, feel free to use and modify these programs for your college practical files, laboratory records, and viva revision. We recommend running and modifying them in our online compiler to solidify your conceptual understanding.

Do I need to create an account?

No, MyCollegeLab is 100% free with no account or login required. You can compile, run, and test code immediately without providing an email address or password.

Can I test programs with custom inputs?

Yes, use the dedicated stdin tab right below the code editor to supply custom inputs for scanf, cin, or input() prior to pressing Run.