All pastes #992408 Raw Edit

code

public text v1 · immutable
#992408 ·published 2008-04-21 20:25 UTC
rendered paste body
#include <iostream.h>

void placeValue(int num, int &thousandValue, int &hundredValue, int &tensValue, int &onesValue){
	
	thousandValue = num/1000;
	hundredValue = (num/100)%10;
	tensValue = (num/10)%10;
	onesValue = num%10;
}

int main(){
	
	int num,thousandValue,hundredValue,tensValue,onesValue;
	cout << "Enter a 4 Digit Number: ";
	cin >> num;
	cout << endl;

	placeValue(num,thousandValue,hundredValue,tensValue,onesValue);

	cout << thousandValue << " is in the thousands value\n";
	cout << hundredValue << " is in the hundreds value\n";
	cout << tensValue << " is in the tens value\n";
	cout << onesValue << " is in the ones position\n";

	return (0);
}