User login
Call 1800-123-2003
Our Schools
SabariGiri Residential School
"Smartindia is the best online tool for school students." Ms Deepa Chandran, Principal Anchal
M. G. M. Model School
"Smartindia is one of the best supplementary education tool for school students." Ms Pooja, Principal
Read More
Demo Video
Ask a Teacher
- CBSE
- ICSE/ISC
- Kerala (English Medium)
-
IGCSE
- All Questions
- Cambridge Pre-Primary 1
- Cambridge Pre-Primary 2
- Cambridge Primary Grade 1
- Cambridge Primary Grade 2
- Cambridge Primary Grade 3
- Cambridge Primary Grade 4
- Cambridge Secondary Grade 5
- Cambridge Secondary Grade 6
- Cambridge Secondary Grade 7
- Cambridge Secondary Grade 8
- Cambridge Secondary Grade 9
- Cambridge Secondary Grade 10
- Cambridge Advanced Grade 11
- Cambridge Advanced Grade 12
develop program to input a program and find the sum of its digits using class and objects |
#include <iostream> void main() { using namespace std; int num, rem, sum=0; //Declaring variables cout<<"Enter a number :"<<endl; cin>>num; //Loop to calculate the sum of the digits of the given number. while(num!=0) { rem=num%10; num=num/10; sum=sum+rem; } cout<<"Sum of the digits is "<<sum<<endl; cin.get( ); } |