Algorithm


1. Start
2. Define a structure named 'Student' with fields for storing information like name, roll number, marks, etc.
3. Declare variables of the 'Student' structure to store information for a specific student.
4. Prompt the user to enter information for the student, such as name, roll number, and marks.
5. Read and store the entered information in the variables of the 'Student' structure.
6. Display the information of the student on the screen.
7. End

Code Examples

#1 Code Example- Store and Display Information Using Structure

Code - C++ Programming

#include <iostream>
using namespace std;

struct student
{
    char name[50];
    int roll;
    float marks;
};

int main() 
{
    student s;
    cout << "Enter information," << endl;
    cout << "Enter name: ";
    cin >> s.name;
    cout << "Enter roll number: ";
    cin >> s.roll;
    cout << "Enter marks: ";
    cin >> s.marks;

    cout << "\nDisplaying Information," << endl;
    cout << "Name: " << s.name << endl;
    cout << "Roll: " << s.roll << endl;
    cout << "Marks: " << s.marks << endl;
    return 0;
}
Copy The Code & Try With Live Editor

Output

x
+
cmd
Enter information,
Enter name: Bill
Enter roll number: 4
Enter marks: 55.6
Displaying Information,
Name: Bill
Roll: 4
Marks: 55.6
Advertisements

Demonstration


C++ Programing Example to Store Information of a Student in a Structure-DevsEnv