Program 1:- Write a function in C++ that exchanges data (passing by references )using swap function to interchange the given two numbers.*/ # include<iostream.h> # include<conio.h> void swap(float &x ,float &y) { float t=x; x=y; y=t; } void main() { void swap(float &,float &); float a,b; cin>>a>>b; cout<<” a := ” << a <<” b := ”<< b<< endl; swap(a,b); cout<< ”a:= ”<< a<< ” b := ”<< b<< endl; } Output : 2 4 a := 2 b:= 4 a:= 4 b: =2 Program 2:- Write a program in C++ with a ratio class using member functions like assign () function to initialize its member data integer numerator and denominator ,convert() function to convert the ratio into double, invert() to get the inverse of the ratio and print() function to print the ratio and its reciprocal.*/ ...
Comments
Post a Comment