I compiles this program it works, but my problem is.

I cannot reset the original values after print the results, so the second function still carries the prevoius results. I want to use the same variable int parmA=12;
int parmB=28; for both functions.

Also any suggestions to get rid of int numerator=12;
int denominator=28; which they have the same values.

A suggestion was int parmA = atoi(argv[1]);int parmB = atoi(argv[2]);, but i have not figure out how to use it.


#include <stdio.h>
#include <stdlib.h>
using namespace std;     

void swapArgs(int *parmA, int *parmB);
void diveArgs( int numerator, int denominator, int *parmA, int *parmB);

int main(int argc, char **argv)
 int numerator=12;
  int denominator=28;
 int parmA=12;
 int parmB=28;

 printf("A=%d, B=%d ",parmA,parmB);
printf("Swapped values A=%d, B=%d.\n",parmA,parmB);

printf("Quotient of %d / %d is ",parmA,parmB);
diveArgs( numerator, denominator, &parmA,&parmB);
printf("%d, remainder is %d\n",parmA,parmB);
 return 0; 


void swapArgs(int *parmA, int *parmB)
 int temp = *parmA;
*parmA = *parmB;
*parmB = temp;

 void diveArgs( int numerator, int denominator, int *parmA, int *parmB)
     *parmA  = numerator   / denominator;
     *parmB = numerator % denominator;
This article has been dead for over six months. Start a new discussion instead.