202: Student Record: Create a struct to represent a student with attributes like name, roll number, and marks in different subjects. Write a program to input details of multiple students and display their information.


// Student Record: Create a struct to represent a student with attributes like name, roll number, and marks in different subjects.
// Write a program to input details of multiple students and display their information.

#include <iostream>
using namespace std;
struct Student
{
    string name, roll_num;
    int bio_marks, phy_marks, comp_marks;
};

Student New_Student();
template <typename T>
T input(string x);
string input_string(string x);
void show_student_data(Student x);

int main()
{
    Student s1 = New_Student();
    Student s2 = New_Student();
    Student s3 = New_Student();

    system("cls");
   
    show_student_data(s1);
    cout << endl;
    show_student_data(s2);
    cout << endl;
    show_student_data(s3);
    cout << endl;

    return 0;
}

Student New_Student()
{
    system("cls");
    Student x;
    x.name = input_string("Enter name: ");
    x.roll_num = input<string>("Enter roll no: ");
    x.bio_marks = input<int>("Enter bio marks: ");
    x.comp_marks = input<int>("Enter computer marks: ");
    x.phy_marks = input<int>("Enter physics marks: ");
    return x;
}

void show_student_data(Student x)
{
    cout << "Name: " << x.name << endl;
    cout << "Roll no: " << x.roll_num << endl;
    cout << "Biology marks: " << x.bio_marks << endl;
    cout << "Physics marks: " << x.phy_marks << endl;
    cout << "Computer marks: " << x.comp_marks << endl;
}

template <typename T>
T input(string x)
{
    T y;
    cout << x;
    cin >> y;
    return y;
}

string input_string(string x)
{
    string y;
    cout << x;
    cin >> y;
    return y;
}

Comments

Popular posts from this blog

88: Using switch statement Write a C program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer. Calculate percentage and grade according to following: // Percentage >= 90% : Grade A Percentage >= 80% : Grade B Percentage >= 70% : Grade C Percentage >= 60% : Grade D Percentage >= 40% : Grade E Percentage < 40% : Grade F

205: Book Catalog: Define a struct to represent a book with attributes like title, author, and publication year. Write a program to create a catalog of books by taking user input and display books published after a certain year.

15: Take input of age and name of 3 people by user and determine oldest and youngest among them with his age. -_-_-_-_-_-_-_-_-(line with spaces input concept)-_-_-_-_-_-_-_-_