Friday, August 8, 2025

STUDENT DATABASE

 #include <iostream>

#include<vector>
#include<list>
#include<map>
#include<unordered_map>
using namespace std;
template<class T1,class T2>
class students{
    public:
    int n;
    map<T1, T2> m;
    students(){
    cout<<" enter the no of students "<<endl;
    cin>>n;
    }
    void input(){
    for(int i=0;i<n;i++){
        T1 name;
        T2 value;
        cin>>name>>value;
        m[name]=value;
    }
    }
    void display(){
        for(auto&p:m){
            cout<<" name of student is "<<p.first<<endl;
             cout<<" ID of student is "<<p.second<<endl;
        }
    }
};
 
 int main() {
 students<string,int>s;
 s.input();
 s.display();
 return 0;
 }

No comments:

Post a Comment

list in c#

  using System ; using System . Collections . Generic ; class Program {     static void Main () {         // Write your C# code here  ...