5) Write a program in C++ to input roll no and marks of three subject of 10 student. Calculate total marks of only those student who secured 35 or more marks in every subject separately. Print roll no and total marks of those student and also count and print number of students which total marks of is not calculated using class and object?

A.

#include<iostream.h>
#include<conio.h>
class student
{
private:
                int rn,s1,s2,s3,tm,n,x;
public:
                void input();
                void calculate();
};
void student::input()
{
                n=0;
                for(int i=0;i<10;i++)
                                {
                                cout<<"Enter Roll No:- ";
                                cin>>rn;
                                cout<<"Enter Marks of Three Subject:- ";
                                cin>>s1>>s2>>s3;
                                if(s1>=35 && s2>=35 && s3>=35)
                                                {
                                                tm=s1+s2+s3;
                                                cout<<"Roll Number:- "<<rn<<endl;
                                                cout<<"Total Marks:- "<<tm<<endl;
                                                }
                                else
                                                n++;
                                }
}
void student::calculate()
{
                cout<<endl<<"No of Student who secured less than 35 marks in any one or more than one subjects:- "<<n<<endl;
}
void main()
{
                student s;
                clrscr();
                s.input();
                s.calculate();
                getch();
}

B.

#include<iostream.h>
#include<conio.h>
class student
{
private:
                int rn,s1,s2,s3,tm;
public:
                void input();
                void output();
};
int n;
void student::input()
{
                cout<<"Enter Roll No:- ";
                cin>>rn;
                cout<<"Enter Marks of Three Subject:- ";
                cin>>s1>>s2>>s3;
}
void student::output()
{
                if(s1>=35 && s2>=35 && s3>=35)
                                {
                                tm=s1+s2+s3;
                                cout<<"Roll No:- "<<rn<<endl;
                                cout<<"Total Marks:- "<<tm<<endl;
                                }
                else
                                n++;
}
void main()
{
                student s;
                clrscr();
                for(int i=0;i<10;i++)
                                {
                                s.input();
                                s.output();
                                }
                cout<<endl<<"Number of Student less than 35 any Subject:- "<<n<<endl;
                getch();
}

 

Advertisements

Comments are closed.

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: