c programming

Wednesday, 19 August 2015

Programming in C to find the sum of the given number

#include<stdio.h>
#include<conio.h>
void main()
{
int n,k=1,sum=0;
clrscr();
printf("Enter a number:");
scanf("%d",&n);
while(n!=0)
{
k=n%10;
sum=sum+k;
k=n/10;
n=k;
}
printf("Sum of the digits: %d",sum);
getch();
}
Posted by Unknown at 05:12
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

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

About Me

Unknown
View my complete profile

Blog Archive

  • ▼  2015 (15)
    • ▼  August (15)
      • Codes for a record entry project
      • Why we learn C language today?
      • C Basic
      • Programming in C to test that the given number is ...
      • Programming in C to find the cube of any number
      • Programming in C to find the square of the given n...
      • Programming in C to reverse a number
      • Programming in C to convert a letter from upper to...
      • Programming in C to find the sum of the given number
      • Programming in C to convert the Decimal number to ...
      • Programming in C to find the factorial of given nu...
      • Structure Of A C Program
      • Programming in C to find the name of the day of th...
      • Programming in C to find the value of any variable...
      • History of C
Travel theme. Powered by Blogger.