#include <stdio.h>
#include <conio.h>
void main()
{
int sum=0,no;
clrscr();
printf("Enter upto four digit number");
scanf("%d",&no);
sum=0;
plus:
sum=sum+no%10;
no=no/10;
if (no>0)
goto plus;
else
printf("sum of digits is %d",sum);
getch();
}
#include <conio.h>
void main()
{
int sum=0,no;
clrscr();
printf("Enter upto four digit number");
scanf("%d",&no);
sum=0;
plus:
sum=sum+no%10;
no=no/10;
if (no>0)
goto plus;
else
printf("sum of digits is %d",sum);
getch();
}
No comments:
Post a Comment