Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
575 B
4
Indexable
Never
#include<iostream>
using namespace std;
void rev_number(int *number);
void rev_number(int *number){
	int n=*(number);
	int rev=0;
	while(n!=0){
		int digit=n%10;
		rev=(rev*10)+digit;
		n=n/10;
	}
	*(number)=rev;
}
int sum_of_digits(int number){
	int sum=0;
	while(number!=0){
		int digit=number%10;
		sum+=digit;
		number/=10;
	}
	return sum;
}
int main(void){
	int number;
	cout<<"Enter the number : ";
	cin>>number;
	rev_number(&number);
	cout<<"After Reversing the number is : "<<number<<endl;
	cout<<"Sum is "<<sum_of_digits(number)<<endl;
}