README.md
December 4, 2022 ยท View on GitHub
Description
Will return 2 values from a function by passing 2 variables by reference.
More Info
| Submitted On | |
| By | Josh Nixon |
| Level | Beginner |
| User Rating | 4.6 (23 globes from 5 users) |
| Compatibility | C++ (general) |
| Category | Coding Standards |
| World | C / C++ |
| Archive File |
API Declarations
#include <iostream.h>
#include <conio.h>
Source Code
#include <iostream.h>
#include <conio.h>
short Math_Stuff(int, int*, int*);
int main()
{
int Num = 0, MCube = 0, MSquared = 0;
short Error;
clrscr();
cout<<"Enter in number to square and cube: ";
cin>>Num;
Error = Math_Stuff(Num, &MCube, &MSquared);
if(!Error)
{
cout<<"The number is: "<<Num;
cout<<endl<<"The cube of "<<Num<<": "<<MCube;
cout<<endl<<"The square of "<<Num<<": "<<MSquared;
getch();
}
else
cout<<"An error has occured";
return 0;
}
short Math_Stuff(int N, int *Cube, int *Sqaured)
{
short Value = 0;
if(N > 20)
Value = 1;
else
*Sqaured = (N*N);
*Cube = (N*N*N);
Value = 0;
return Value;
}