• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Technology blog

Technology Blog

  • Tech Updates
  • SEO
  • Reviews
  • Google
  • Blogging
  • Windows
  • Downloads
  • Earn-Money Online
  • Android

C++

C++ Program to find Sum of Digits of a number : Windows and Linux

May 12, 2014 by Technology Blog Leave a Comment


This C++ program can find the sum of digits of a number. User needs to enter a number for example, take number xyz. Why user enters this number, computer will say, the answer is x+y+z. 
For example if the number is 101, the result should be 1+0+1 ie, 2.

Program to Find Sum of Digits

#include<iostream.h>
#include<conio.h>
Int main()
 {
   int n,temp,s=0;
   cout<<“Enter Your Number: “;
   cin>>n;
   while(n>0)
       {
         a=n%10;
         n/=10;
         s+=a;
        }
   cout<<“Sum of Digits: “<<s;
   getch();
   Return(0);

Output

Enter Your Number: 101
Sum of Digits: 2

Filed Under: C++

Primary Sidebar

Copyright © 2025 TechieFeeds.com