This Program is to declare structure student.I have taken input for 5 students and then find the details of student such as name roll no, percentage ,student name, and roll no. Over here we have made a structure named student which consists of roll no, student name and percentage.
Code:
# include<iostream.h>
# include<conio.h>
struct student
{
int rollno;
char student_name[40];
float percentage;
}
main()
{
struct student s[5];
int i;
clrscr();
cout<<”enter data for 5 students”;
for(i=0;i<=4;++i)
{
cout<<”Enter students rollno, name and percentage”;
cin>>s[i].rollno>>s[i].student_name>>s[i].percentage;
}
for( i=0;i<4;++i)
{
cout<<”Students Roll no = ”<<s[i].rollno;
cout<<”Students name =”<<s[i].student_name;
cout<<”Students percentage= “<<percentage;
}
}
Bookmarks