Structure in Main Function

#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
    struct anik
    {
        string name;
        string id;
        double cg;
    };
    anik a;

    cout << "Enter Name : ";
    getline(cin, a.name);

    cout << "Enter ID : ";
    getchar();
    cin >> a.id;

    cout << "Enter CGPA : ";
    cin >> a.cg;

    cout << endl << endl << "Name : " << a.name << endl;
    cout << "ID : " << a.id << endl;
    cout << "CGPA : " << a.cg << endl;

    return 0;
}

Comments