#include<stdio.h>
#include<stdio.h>
void main()
{
int n,sum,p;
clrscr();
printf("enter the possitive integer:");
scanf("%d",&n);
sum=0;
if(n<0)
printf("\n the given number is not valid(not +ve)");
else
{
while(n!=0)
{
p=n%10;
n=n/10;
sum=sum+p;
}
printf("\n sum of individual digits is:%d",sum);
}
getch();
#include<stdio.h>
void main()
{
int n,sum,p;
clrscr();
printf("enter the possitive integer:");
scanf("%d",&n);
sum=0;
if(n<0)
printf("\n the given number is not valid(not +ve)");
else
{
while(n!=0)
{
p=n%10;
n=n/10;
sum=sum+p;
}
printf("\n sum of individual digits is:%d",sum);
}
getch();
No comments:
Post a Comment