C Program Diary

Tuesday, October 16, 2012

Program To Find Sum Of Digit


Some Basic C program frequently asked in Interview.

/* Program to find sum of digit of a number*/ 


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,s=0;
clrscr();
printf("Enter a number:\t");
scanf("%d",&a);
while(a>0)
{
b=a%10;
s=s+b;
a=a/10;
}
printf("Sum of digit is %d",s);
getch();
}
Posted by Abc at 11:59 AM
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)

Blog Archive

  • ▼  2012 (17)
    • ▼  October (17)
      • Copy Constructor & this pointer
      • Operator Overloading Program
      • Default Arguments Program
      • Program To Find Sum Of Digit
      • Program To Convert a Number into Binary
      • Program to check a prime number.
      • Program to Calculate power of a number
      • Program To check a Number is Pallindrome & Armstrong
      • C program to replace multiple spaces with a single...
      • Count number of words in a string
      • Frequently asked C programs
      • Binary Search Tree
      • Stack implementation using C++
      • Insertion Sort algorithm in C++
      • Linked List Implementation using C++
      • Merge Sort program in c in a simple way:
      • Simple Linked List Program to add a node

About Me

Abc
View my complete profile
Awesome Inc. theme. Powered by Blogger.