Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

#include<iostream>

using namespace std;


int main()
{ int firstnumber,secondnumber,*first,*second;

first=&firstnumber;
second=&secondnumber;

cout<<"Enter first number"<<endl;


cin>>firstnumber;
cout<<"Enter second number"<<endl;
cin>>secondnumber;
if(*first>*second){

cout<<"Maximum Number is="<<*first<<"Minimum


is="<<*second<<endl;

}else{

cout<<"Maximum="<<*second<<" and
Minimum="<<*first<<endl;

return 0;
}
#include<iostream>
#include <stdio.h>
using namespace std;
void swapNumbers(int *x,int *y,int *z);
int main()
{
int e1,e2,e3;

cout<<" Input the value of 1st element : ";


cin>>e1;
cout<<" Input the value of 2nd element : ";
cin>>e2;
cout<<" Input the value of 3rd element : ";
cin>>e3;

cout<<"\n The value before swapping are :\n";


cout<<"element 1 = "<<e1<<"\nelement 2 = "<<e2<<"\
nelement 3 ="<<e3<<" \n\n";
swapNumbers(&e1,&e2,&e3);
cout<<"\n The value after swapping are :\n";
cout<<"element 1 = "<<e1<<"\nelement 2 = "<<e2<<"\
nelement 3 ="<<e3<<" \n\n";
return 0;
}
void swapNumbers(int *x,int *y,int *z)
{
int tmp;
tmp=*y;
*y=*x;
*x=*z;
*z=tmp;
}

You might also like