In the User defined function sum(), i am getting the Lvalue required error, can you please tell me why?
#include<iostream.h>
#include<conio.h>
#include<math.h>
int num,digit,sum1,p;
int sqlarge(int &a, int &b, int t=0)
{
if(a>b)
{
t=a;
a=pow(t,2);
return a; }
if(a<b)
{
t=b;
b=pow(t,2);
return b; }
else
{cout<<"Both values can never be equal"<<endl;
return NULL; }
}
int sum(int a)
{
do
{
digit=a%10;
num=a/10;
p=digit+num;
sum1++=p;
}
while(num !=0);
return sum1;
}
int main()
{
clrscr();
int a,b,n;
cout<<"Enter two values"<<endl;
cin>>a>>b;
cout<<"Square of the larger value is ";
n=sqlarge(a,b);
cout<<n;
cout<<"Sum of the digits of squared larger value is ";
cout<<sum(n);
getch();
return 0;
}