Computer Science and Applications (Practical Notebook)
Computer Science and Applications (Practical Notebook)
Year: 2025
Submitted By: [Your Name]
Submitted To: [Teacher/Institution]
Table of Contents
1. C++ Programming Tasks
- Managing Bank Account
- Polymorphism Using Function Overloading
- Selection Sorting
- Multilevel Inheritance
- Visibility Modes
2. SQL Queries
3. Project Work
4. Practical File Summary
5. Viva Voce Questions
1. C++ Programming Tasks
(a) Managing Bank Account
Question:
Write a program in C++ to manage the bank account of a person.
Computer Science and Applications (Practical Notebook)
Answer:
#include <iostream>
using namespace std;
class BankAccount {
string name;
int accountNumber;
double balance;
public:
BankAccount(string n, int acc, double bal) : name(n), accountNumber(acc), balance(bal) {}
void deposit(double amount) {
balance += amount;
cout << "Deposited: " << amount << ", New Balance: " << balance << endl;
void withdraw(double amount) {
if (amount > balance)
cout << "Insufficient balance!" << endl;
else {
balance -= amount;
cout << "Withdrawn: " << amount << ", New Balance: " << balance << endl;
void display() {
Computer Science and Applications (Practical Notebook)
cout << "Name: " << name << ", Account Number: " << accountNumber << ", Balance: " << balance << endl;
};
int main() {
BankAccount acc("John Doe", 12345, 1000.0);
acc.display();
acc.deposit(500.0);
acc.withdraw(200.0);
acc.display();
return 0;
Explanation:
This program manages a bank account by allowing deposit, withdrawal, and balance inquiry.
Output:
Name: John Doe, Account Number: 12345, Balance: 1000
Deposited: 500, New Balance: 1500
Withdrawn: 200, New Balance: 1300
(b) Polymorphism Using Function Overloading
Question:
Write a program in C++ to show polymorphism using function overloading.
Computer Science and Applications (Practical Notebook)
Answer:
#include <iostream>
using namespace std;
class Calculator {
public:
int add(int a, int b) {
return a + b;
double add(double a, double b) {
return a + b;
int add(int a, int b, int c) {
return a + b + c;
};
int main() {
Calculator calc;
cout << "Sum (int, int): " << calc.add(3, 5) << endl;
cout << "Sum (double, double): " << calc.add(2.5, 4.5) << endl;
cout << "Sum (int, int, int): " << calc.add(1, 2, 3) << endl;
return 0;
}
Computer Science and Applications (Practical Notebook)
Explanation:
This program demonstrates polymorphism by overloading functions to handle different parameter types.
Output:
Sum (int, int): 8
Sum (double, double): 7.0
Sum (int, int, int): 6