My Professional Profile

I am Johnson Augustine Sr.Software Engineer and System Architect. I have 10 Yrs of hands on expertise in ASP.net MVC 5 , Angular 5 , C# MVC Razor, WPF MVVM , Android , IOS Swift 3 , IOS11 MSSQL,MySQL Database,,PHP,C/C++/Visual C++/G++/QT++,Com,DirectX,Open CV,EMGU CV , embedded System Development , [Raspberry PI]. ,html,Javascript,Jquery,Ajax.CSS , Networking ,Cyber security, Ethical Hacking You can see my professional profile at http://linkedin.com/in/johnsontaugustine Email : johnsonaugustine@live.com

Saturday, 19 January 2013

A program to find sum of digits repeatedly until a single digit is obtained?

A program to find sum of digits repeatedly until a single digit is obtained?


#include<stdio.h>
#include<conio.h>
main()
{
int n,s=0,sum=0,i,d;

printf("enter the number");
scanf("%d",&n);
while(n>0)
{
d=n%10;
s=s+d;
n=n/10;
}
while(s>0)
{
i=s%10;
sum=sum+i;
s=s/10;
}
printf("%d",sum);
getch();
}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.