Structure in CPP

The structure is a group of the different data type.

#include<iostream.h>
#include<conio.h>


struct student            // it will create a new data type.
{
int rollno;
char name[10];        // student is a data type.
int mark;
};

void main()
{
clrscr();

student s1;   // structure variable

cout << "enter any rollno" ;
cin >> s1.rollno;

cout << "enter any name" ;
cin >> s1.name ;

cout << "enter marks";
cin >> s1.mark;

cout << s1.rollno << " " << s1.name << " " << s1.mark << endl;
getch();
}

Leave a Reply