Computer Science, asked by dhruvsharma27022, 1 month ago

Write a program to declare two variables in class and swap it using class in C++.

Answers

Answered by madhavirameshr
1

Answer:class swap

{

int a,b;

public:

void getdata();

void swapv();

void display();

};

void swap::getdata()

{

cout<<“Enter two numbers:”;

cin>>a>>b;

}

void swap::swapv()

{

a=a+b;

b=a-b;

a=a-b;

}

void swap::display()

{

cout<<“a=”<<a<<“tb=”<<b;

}

main()

{

clrscr();

swap s;

s.getdata();

cout<<“nBefore swap:n”;

s.display();

s.swapv();

cout<<“nnAfter swap:n”;

s.display();

getch();

return 0;

}

Explanation:

hope it help pls mark me as brainliest

Answered by ruthwiksunny234
0

Answer:

Explanation:

a=input("enter a string")

print(a.swapcase())

Similar questions