#include(stdio.h) // place this '<' & '>' instead of '(' & ')' before stdio.h
#include(conio.h)
int main(void)
{
int no, rem, sum=0;
clrscr();
printf("Enter the required number:");
scanf("%d",&no);
while(no>0)
{
rem=no%10;
sum=sum+rem;
no=no/10;
}
printf("\nSum of individual digits of a positive integer is: %d",sum);
getch();
return 0;
}
Note:- here 'rem' means remainder
No comments:
Post a Comment