Wednesday, October 19, 2011

Program:To calculate sum of digits of a three digit number




#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,a,b,c,d;
cout<<"Enter 3 digit no. :"<<endl;
cin>>n;
a=n%10;
n=n/10;
b=n%10;
c=n/10;
d=a+b+c;
cout<<endl<<"The sum is : "<<d;
getch();
}

Article by
Chief-Editor

He is a tech Enthusiast, an Altruist and calm mentor. He loves to code. He is also a creative graphic designer. Do check out his designfolio @ Jasmeet.asia If you like This post, you can follow me on Twitter.



For Further Reading,
C++ Program

0 comments:

Post a Comment