NOTE.CS
All Problem Solving C++ C# Java Algorithm Data Structure OOP Database Computer Network Operating System Software Engineering General Research Paper Artificial Intelligence Demo Laravel PHP JavaScript React.js Next.js
Login
All topics PDF
18

Sum of Digits

Problem Solving
C++ 6 lines
1 2 3 4 5 6
int n = 1234, sum = 0;
while(n > 0){
    sum += n % 10;
    n /= 10;
}
cout << sum; // 10
Previous Next
NOTE.CS

A focused revision library for Computer Science & Engineering: clear notes, working code, figures and viva questions in one place.

Categories
  • Problem Solving
  • C++
  • C#
  • Java
  • Algorithm
  • Data Structure
 
  • OOP
  • Database
  • Computer Network
  • Operating System
  • Software Engineering
  • All Topics
About the author
KB
Kaushik Biswas
Software Engineer
  • M.Sc. in CS (Intelligent Systems), AIUB
  • B.Sc. in CSE (Software Engineering), AIUB
View portfolio
© 2026 NOTE.CS. All rights reserved. Designed & developed by Kaushik Biswas