Nothing Special   »   [go: up one dir, main page]

Thapar Object Oriented Programming Assignment Lab 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

ASSIGNMENT-1

1.
#include<iostream>

Using namespace std;

int main()

cout<<"Hello World";

return 0;

2.
#include<iostream>

using namespace std;

int main()

cout<<"hello \t world"<<endl;

cout<<"hello"<<endl<<"world"<<endl;

cout<<"\a";

cout<<"hello world \r";

return 0;

3. #include <iostream>
using namespace std;

namespace first_space

void func()

cout << "Inside first_space" << endl;

namespace second_space

void func()
{

cout << "Inside second_space" << endl;

int main ()

first_space::func();

second_space::func();

return 0;

4.
#include<iostream>

using namespace std;

struct student

char name[40];

int roll;

float marks;

void setStudentData()

cout<<"enter name of student";

cin>>name;

cout<<"enter roll number of student";

cin>>roll;

cout<<"enter marks of student";

cin>>marks;

void getStudentData()

cout<<"name:"<<name<<endl<<"roll number:"<<roll<<endl<<"marks:"<<marks<<endl;

};

int main()

{
int i;

student s[3];

for(i=0;i<3;i++)

struct student s1;

s1.setStudentData();

s1.getStudentData();

return 0;

5.
#include<iostream>

using namespace std;

struct student

private:

char name[40];

int roll;

float marks;

public:

void setStudentData()

cout<<"enter name of student";

cin>>name;

cout<<"enter roll number of student";

cin>>roll;

cout<<"enter marks of student";

cin>>marks;

void getStudentData()

cout<<"name:"<<name<<endl<<"roll number:"<<roll<<endl<<"marks:"<<marks<<endl;

}
};

int main()

int i;

student s[3];

for(i=0;i<3;i++)

struct student s1;

s1.setStudentData();

s1.getStudentData();

return 0;

6.
#include<iostream>

using namespace std;

class student

public:

char name[40];

int roll;

float marks;

void setStudentData()

cout<<"enter name of student";

cin>>name;

cout<<"enter roll number of student";

cin>>roll;

cout<<"enter marks of student";

cin>>marks;

void getStudentData()
{

cout<<"name:"<<name<<endl<<"roll number:"<<roll<<endl<<"marks:"<<marks<<endl;

};

int main()

int i;

student s[3];

for(i=0;i<3;i++)

student s1;

s1.setStudentData();

s1.getStudentData();

return 0;

Name – Prabhdeep singh


Class – 1EM2
Roll Number - 102119034

You might also like