You are on page 1of 4

CS-305 EXPERIMENT – 7

NAME : ADARSH DUBEY

ROLL NO. : 0905CS191016

CLASS : CSE-A

SEM : III SEM (Jul-dec,2020)

SUBMITTED TO : Ms. REENA CHAUHAN

7)
● Program in C++ to use scope resolution operator.
● Display the various values of the same variables declared
at different scope levels.

#include<iostream>

using namespace std;

float sum = 0; // Global Variable

class Marks

private:

float s[5];

public:

void getmarks();

void putmarks();

};

void Marks::getmarks() //calling class function using S.R.O


{

for(int i=0;i<5;i++)

cout<<"Enter marks for subject "<<i+1<<" = ";

cin>>s[i];

void Marks::putmarks() //calling class function using S.R.O

for(int i=0;i<5;i++)

cout<<"Marks of subject "<<i+1<<" = "<<s[i]<<endl;

sum = sum + s[i];

if(i==4)

cout<<"Total numbers = "<<sum<<"/500"<<endl;

sum = 0;

int main()

int s; //Local variable

cout<<"Enter the number of student info you want TO pass : ";

cin>>s;
Marks m[s];

for(int i=0;i<s;i++)

cout<<"\nEnter information for student : "<<i+1<<endl;

m[i].getmarks();

for(int i=0;i<s;i++)

cout<<"\nDisplaying information of student :

"<<i+1<<endl;

m[i].putmarks();

return 0;

Output;;

You might also like