Write a C++ Program to Store and Display Information Using Structure

C++ Program to Store and Display Information Using Structure

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn C++ programming concepts. You can learn C++ language at your own speed and time. One can learn concepts of C++ language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

C++ Program to Store and Display Information Using Structure
C++ Program to Store and Display Information Using Structure

Write a C++ Program to Store and Display Information Using Structure

PROGRAM:C++ Program to Store and Display Information Using Structure

/* C++ Program to Store and Display Information Using Structure */

#include <iostream>
using namespace std;

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

int main()
{
cout << “Enter information of students: ” << endl;

// storing information
for(int i = 0; i < 10; ++i)
{
s[i].roll = i+1;
cout << “For roll number” << s[i].roll << “,” << endl;

cout << “Enter name: “;
cin >> s[i].name;

cout << “Enter marks: “;
cin >> s[i].marks;

cout << endl;
}

cout << “Displaying Information: ” << endl;

// Displaying information
for(int i = 0; i < 10; ++i)
{
cout << “\nRoll number: ” << i+1 << endl;
cout << “Name: ” << s[i].name << endl;
cout << “Marks: ” << s[i].marks << endl;
}

return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *