/*Serial No.61 [swami34.cpp]*/
#include<stdio.h>
#include<conio.h>
digit(int);
void main()
{
int num,f;
clrscr();
printf("Enter the any digit number==>");
scanf("%d",&num);
f=digit(num);
printf("\nSum of %d is==> %d",num,f);
getch();
}
digit(int k)
{
int sum=0;
if(k>0)
{
sum=k%10+digit(k/10);//recursion function call
}
return (sum);
}
#include<stdio.h>
#include<conio.h>
digit(int);
void main()
{
int num,f;
clrscr();
printf("Enter the any digit number==>");
scanf("%d",&num);
f=digit(num);
printf("\nSum of %d is==> %d",num,f);
getch();
}
digit(int k)
{
int sum=0;
if(k>0)
{
sum=k%10+digit(k/10);//recursion function call
}
return (sum);
}
No comments:
Post a Comment
If you have any doubt, feel free to ask...