Skip to content

Instantly share code, notes, and snippets.

@jkotra
Last active May 11, 2019 04:41
Show Gist options
  • Save jkotra/b8047afab7575a0fc8ff3b02a9f1ec0d to your computer and use it in GitHub Desktop.
Save jkotra/b8047afab7575a0fc8ff3b02a9f1ec0d to your computer and use it in GitHub Desktop.
#include <iostream>
#include <conio>
using namespace std;
int main()
{
long a = 0;
int b = 0;
clrscr();
cout << "sum of digits of input number" << endl;
cout << "enter a number" << endl;
cin >> a;
while(a!=0){
b = b+(a%10);
a = a/10;
}
cout << "required sum:" << b;
getch();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment