Page MenuHomec4science

exercise05-3.cpp
No OneTemporary

File Metadata

Created
Mon, Jul 7, 22:06

exercise05-3.cpp

/*
* exercise05-1.cpp
*
/*
* Any headers you need to include should be specified on the next lines
*/
#include <iostream>
void swapVal(double *ptrA, double *ptrB);
int main(int argc, char* argv[])
{
double a = 5;
double b = 7;
double *ptrA = &a;
double *ptrB = &b;
std::cout << "Value before :"<< a << b << std::endl;
swapVal(ptrA, ptrB);
std::cout << "Value after : "<< a << b << std::endl;
return 0;
}
void swapVal(double *ptrA, double *ptrB)
{
double dmy;
dmy = *ptrB;
*ptrB = *ptrA;
*ptrA = dmy;
}

Event Timeline