Documentation
Output
Student Details
Roll No: 101
Name: Rahul
Grade: A
structis used to group different data types.-
Members are accessed using the dot (.) operator.
-
Structure variables can be initialized at declaration.
#include <iostream>
using namespace std;
struct Student {
  int rollNo;
  char name[20];
  char grade;
};
int main() {
  // Initializing structure variables
  Student s1 = {101, "Rahul", 'A'};
  // Displaying structure contents
  cout << "Student Details" << endl;
  cout << "Roll No: " << s1.rollNo << endl;
  cout << "Name: " << s1.name << endl;
  cout << "Grade: " << s1.grade << endl;
  return 0;
}
Output
Student Details
Roll No: 101
Name: Rahul
Grade: A
struct is used to group different data types.Members are accessed using the dot (.) operator.
Structure variables can be initialized at declaration.