Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

WAP to create a class for students to get and print details of a student.

Input:

#include <iostream>

using namespace std;

class student

private:

char name[30];

int rollNo;

int total;

float perc;

public:

void getDetails(void);

void putDetails(void);

};

void student::getDetails(void){

cout << "Enter name: " ;

cin >> name;

cout << "Enter roll number: ";

cin >> rollNo;

cout << "Enter total marks out of 500: ";

cin >> total;

perc=(float)total/500*100;

void student::putDetails(void)

cout << "Student details:\n";

cout<<"Name:"<<name<<"\n";

cout<<"Roll no:"<<rollNo<<"\n";

cout<<"Total:"<<total<<"\n";

cout<<"Percentage:"<<perc<<"\n";
}

int main()

student std;

std.getDetails();

std.putDetails();

return 0;

Outupt:

Enter name: Sarthak

Enter roll number: 2337

Enter total marks out of 500: 350

Student details:

Name:Sarthak

Roll no:2337

Total:350

Percentage:70

You might also like