#include<iostream>
using namespace std;
struct student{ /*declaring the structure*/
int rollno;
char name[30];
char std[5];
};
int main()
{
student su[50];
int n;
cout<<"Enter how many students to feed data : ";
cin>>n;
cout<<"\n\n";
for(int i=0;i<n;++i)//input for the structure
{
cout<<"Enter details of student "<<i+1<<"\n\n";
cout<<"Enter Roll NO. : ";
cin>>su[i].rollno;
fflush(stdin);
cout<<"Enter Name : ";
cin.getline(su[i].name,28);
cout<<"Enter Class : ";
cin.getline(su[i].std,5);
}
cout<<"\n\n";
cout<<"Details about students are as follows :---\n\n";
for(int i=0;i<n;++i)//displaying
{
cout<<"\nRoll NO. : "<<su[i].rollno;
cout<<"\nName : "<<su[i].name;
cout<<"\nClass : "<<su[i].std;
}
return 0;
}
using namespace std;
struct student{ /*declaring the structure*/
int rollno;
char name[30];
char std[5];
};
int main()
{
student su[50];
int n;
cout<<"Enter how many students to feed data : ";
cin>>n;
cout<<"\n\n";
for(int i=0;i<n;++i)//input for the structure
{
cout<<"Enter details of student "<<i+1<<"\n\n";
cout<<"Enter Roll NO. : ";
cin>>su[i].rollno;
fflush(stdin);
cout<<"Enter Name : ";
cin.getline(su[i].name,28);
cout<<"Enter Class : ";
cin.getline(su[i].std,5);
}
cout<<"\n\n";
cout<<"Details about students are as follows :---\n\n";
for(int i=0;i<n;++i)//displaying
{
cout<<"\nRoll NO. : "<<su[i].rollno;
cout<<"\nName : "<<su[i].name;
cout<<"\nClass : "<<su[i].std;
}
return 0;
}
0 comments:
Post a Comment