Showing posts with label object array and modifications. Show all posts
Showing posts with label object array and modifications. Show all posts

Friday, April 22, 2022

SIMPLE ARRAY OF OBJECT AND DATA MODIFICATION

 #include <iostream>

using namespace std;
#include <conio.h>
class base
{
protected:
    string name;
    long long int rollno, phno;
    string address;

public:
    void getdata()
    {
        cout << "\nENTER NAME:" << endl;
        cin >> name;
        cout << "\nENTER ROLL NO.:" << endl;
        cin >> rollno;
        cout << "\nENTER PHONE NO. :"
             << endl;
        cin >> phno;
        cout << "\nENTER ADDRESS:"
             << endl;
        cin >> address;
    }
};
class derived : public base
{
private:
    long long int s1, s2, total;

public:
    void getdataderived()
    {
        cout << "\nENTER MARKS OF FIRST SESSIONAL:" << endl;
        cin >> s1;
        cout << "\nENTER MARKS OF SECOND SESSIONAL::" << endl;
        cin >> s2;
        total = (int)(s1 + s2);
    }
    void showdetails()
    {
        cout << "NAME IS " << name << endl;
        cout << "ROLL NO. IS " << rollno << endl;
        cout << "PHONE NO. IS " << phno << endl;
        cout << "ADDRESS IS " << address << endl;
        cout << "TOTAL MARKS ARE  " << total << endl;
    }
};
int main()
{
    system("cls");
    int size;
    cout << "ENTER THE NUMBER OF STUDENTS YOU WANNA SAVE DATA OF\n";
    cin >> size;
    derived obj[size];
    for (int i = 0; i < size; i++)
    {
        cout << "ENTER THE DATA OF STUDENT: " << i + 1 << endl;
        obj[i].getdata();
        obj[i].getdataderived();
        system("cls");
    }
    system("cls");
    cout << "DATA OF STUDENT BEFORE ANY MODIFICATIONS\n";
    for (int i = 0; i < size; i++)
    {
        cout << "DATA OF STUDENT " << i + 1 << endl;
        obj[i].showdetails();
        cout << endl;
    }
    int serial;
    cout << "ENTER SERIAL NUMBER OF STUDENT YOU WANNA MODIFY DATA OF\n";
    cin >> serial;
    cout << "ENTER THE NEW DATA\n";
    obj[serial - 1].getdata();
    obj[serial - 1].getdataderived();
    system("cls");
    cout << "DATA OF STUDENT AFTER MODIFICATIONS\n";
    for (int i = 0; i < size; i++)
    {
        cout << "DATA OF STUDENT " << i + 1 << endl;
        obj[i].showdetails();
        cout << endl;
    }

    return 0;
}

Software scope

 In software engineering, the software scope refers to the boundaries and limitations of a software project. It defines what the software wi...

Popular Posts