Notes

Sunday, December 23, 2012

Write a program to find the sum of the digits of a number.

SCREENSHOTS

 

 To Download The FILES
------ClickHere-------

 

CODE

Starts from here ----------->>
#include<iostream.h>
#include<conio.h>
 int sod(int);
 void main()
  { int n;
    clrscr();
    cout<<"\nEnter: ";
    cin>>n;
    cout<<"\nSum of the digits of "<<n<<" is "<<sod(n)<<".";
    getch();
  }
 int sod(int d)
  { int x=0,i;
    while(d>0)
     { i=d%10;
       x+=i;
       d=d/10;
     }
    return x;
  }

<<------------Ends Here
Posted by Unknown at 7:35 PM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: C++

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Categories

  • Accountancy (1)
  • Business Studies (3)
  • C (1)
  • C++ (6)
  • Class - XII (8)
  • Eclipse (2)
  • Economics (3)
  • English (1)
  • JAVA (2)

About Me

Unknown
View my complete profile

Top 5 Posts of the Week

Popular Posts(All Time)

  • POSTER
  • Essential Features or Characteristics Of Partnership
  • Define Management.
  • What is Economy?
  • Scarcity
  • Relation between Efficiency and Effectiveness
  • Write a program to find the reverse of an inputted number.
  • What is economics all about?
  • Write a program for matrix addition, subtraction and multiplication.
  • Efficiency vs Effectiveness

Blog Archive

  • ►  2013 (13)
    • ►  March (8)
    • ►  January (5)
  • ▼  2012 (6)
    • ▼  December (6)
      • Write a program for matrix addition, subtraction a...
      • Write a program to print the Fibonacci series.
      • Write a program to find the factorial of a number.
      • Write a program to find the sum of the digits of a...
      • Write a program to find the reverse of an inputted...
      • Write a program to check whether the number is pri...
Ethereal theme. Powered by Blogger.