i wrote this program,there are some problems
Code:
#include <stdio.h>
long int pow(int a,int b){
int x=0,y=1;
while(x<b){
y*=a;
x++;}
return y;}
int rakam_top(long int a){
int x=10,y=0;
while((x<=a)&&(x%10==0)){
if (x==10){y+=a%x;}
y+=a/x;
x*=10;}
return y;}
int main(){
int x,y;
long int z;
printf ("X raised to power of Y \n\n X=");
scanf ("%i",&x);
getchar();
printf ("\n Y=");
scanf ("%i",&y );
getchar();
z = pow(x,y);
printf("\n %i raised to the power %i = %ld \n",x,y,z);
printf("\n Digit sum= %i \n",rakam_top(z));
getchar();
return 0;}
when i declare x=2 and y=15
it finds the pow. right but Digit sum finds 3646/
when i declare x=2 and y=100
it return pow. 0