0% found this document useful (0 votes)
6 views6 pages

Swaraj Practical 2 (C++)

Uploaded by

swarajsk2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

Swaraj Practical 2 (C++)

Uploaded by

swarajsk2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

PRACTICAL 2

Name: Kale Swaraj Sunil


Roll no: 20[A1] OOPs
//Scope Resolution

#include<iostream.h>

#include<conio.h>

int a=5;

float b=8.54;

void main()

int a=978;

float b=88.89;

clrscr();

cout<<"the value of global


value="<<::a<<endl;

cout<<"the value of global


value="<<::b<<endl;

cout<<"the value of local value="<<b<<endl;

getch();

Output:
PRACTICAL 2
Name: Kale Swaraj Sunil
Roll no: 20[A1] OOPs
#include <iostream>

using namespace std;

class MyClass

public:

void display();

};

void MyClass::display()

cout<<"Hello" << endl;

int main() {

MyClass obj;

obj.display();

return 0;

Output:
PRACTICAL 2
Name: Kale Swaraj Sunil
Roll no: 20[A1] OOPs
#include <iostream.h>

#include <iomanip.h>

int main()

cout << setw(30) << "Welcome to the world


of C++" << endl;

return 0;

Output:
PRACTICAL 2
Name: Kale Swaraj Sunil
Roll no: 20[A1] OOPs
#include <iostream>

using namespace std;

int main()

int* ptr = new int;

*ptr = 42;

cout << "Value: " << *ptr << endl;

cout << "Address: " << ptr << endl;

delete ptr;

ptr = nullptr;

return 0;

Output:
PRACTICAL 2
Name: Kale Swaraj Sunil
Roll no: 20[A1] OOPs
Practical 2

Swaraj Sunil Kale


rollno:20(A1)

#include<iostream.h>

#include<conio.h>

static int s=250;

int n=370;

void main()

int n=500;

clrscr();

cout<<"value of Local variable n is=


"<<n<<endl;

cout<<"value of Global variable n is=


"<<::n<<endl;

cout<<"value of Static variable s is=


"<<s<<endl;

getch();

output:
PRACTICAL 2
Name: Kale Swaraj Sunil
Roll no: 20[A1] OOPs
practical 2

Swaraj Kale output:


rollno: 20(A1)

//Manipulators

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

void main()

int s=6745;

float pi=3.14159265;

clrscr();

cout<<" Setwidth
manipulator="<<setw(12)<<s<<endl;

cout<<"\
n"<<setw(25)<<setiosflags(ios::right)<<"Rama"<
<endl;

cout<<"\n Setfill:"<<" aadhar no


="<<setw(12)<<setfill('x')<<s<<endl;

cout<<"\n Setpricision:"<<ends<<" Value of


Pi="<<ends<<setprecision(6)<<pi<<endl;

cout<<"\n Hexadecimal of 6745 "<<" =


"<<setbase(16)<<s<<endl;

cout<<"\n Octal of 6745"<<" =


"<<setbase(8)<<s<<endl;

getch();

You might also like