Code:
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
struct student
{
char name[20];
int id;
float cgpa;
};
int main()
{
student s[100];
int n,i;
cout<<"Enter number of students: ";
cin>>n;
cout<<"Enter records of "<<n<<" students"<<endl;
for(i=0; i<n ; i++)
{
cout<<"Enter name: ";
gets(s[i].name);
cout<<"Enter ID: ";
cin>>s[i].id;
cout<<"Enter CGPA: ";
cin>>s[i].cgpa;
cout<<endl;
}
for(i=0; i<n ; i++)
{
cout<<"\nName: "<<s[i].name;
cout<<"\nID: "<<s[i].id;
cout<<"\nCGPA: "<<s[i].cgpa<<endl;
}
}
output:
Enter number of students: 2
Enter records of 2 students
Enter name: Enter ID:
using sublime text 3 c++