Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
13 views

Assignment 4B

Uploaded by

madnessison
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Assignment 4B

Uploaded by

madnessison
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment 4B

//Name : Tanushka Patil


//Roll no. : FY23I036
//PRN : 123B1B036

#include<iostream>
using namespace std;
int main() {
int *ptr1 = new int(10) ;
float *ptr2 = new float(10.50) ;

cout << "PTR 1 : " << *ptr1 << endl ;


cout << "PTR 2 : " << *ptr2 << endl ;

delete[]ptr1 ;
delete[]ptr2 ;

cout << ptr1 << endl ;


cout << ptr2 << endl ;

return 0 ;
}
Assignment 6

//Name : Tanushka Patil


//Roll no. : FY23I036
//PRN : 123B1B036

#include<iostream>
using namespace std;

class student {
private:
string name;
int marks[5];
int totalmarks;
int maxmarks;
float avg;
char grade;
float per;

public:
void assign(string n, int m[]);
int computeMarks();
float computeAvg();
float computePer();
void display();
};

void student::assign(string n, int m[]) {


name = n;
for (int i = 0; i < 5; i++) {
marks[i] = m[i];
}
return;
}

int student::computeMarks() {
totalmarks = 0;
for (int i = 0; i < 5; i++) {
totalmarks = totalmarks + marks[i];
}
return totalmarks;
}

float student::computeAvg() {
computeMarks();
avg = totalmarks / 5;
return avg;
}

float student::computePer() {
computeMarks();
per = (totalmarks / 500.0) * 100;
if (per > 90)
grade = 1 ;
else if (90 <= per < 75)
grade = 2 ;
else if (75 <= per < 50)
grade = 3 ;
else if (50 <= per < 35)
grade = 4 ;
else
grade = 5 ;
switch(grade) {
case 1 : cout << "Remark : Excellent " << endl ;
break ;
case 2 : cout << "Remark : Good " << endl ;
break ;
case 3 : cout << "Remark : Can do better " << endl ;
break ;
case 4 : cout << "Remark : Needs improvement " << endl ;
break ;
case 5 : cout << "Remark : Fail " << endl ;
break ;
}
return per ;
}

void student::display() {
computeMarks();
cout << "Total marks are : " << totalmarks << endl;
computeAvg();
cout << "Average marks are : " << avg << endl;
computePer() ;
cout << "Percentage is : " << per << endl;
return;
}

int main() {
student s[3];
string n;
int m[5];

for (int i = 0; i < 10; i++) {


cout << "Enter name of the student : ";
cin >> n;
cout << "Enter marks out of 100 : " << endl;
for (int j = 0; j < 5; j++) {
cin >> m[j];
}
s[i].assign(n, m);
s[i].computeMarks();
s[i].computeAvg();
s[i].computePer();
s[i].display();
}

return 0;
}

You might also like