C PROGRAM TO FIND THE SUM OF INDIVIDUAL DIGITS OF A POSITIVE INTEGER | Indian Shout

You are here: » C PROGRAM TO FIND THE SUM OF INDIVIDUAL DIGITS OF A POSITIVE INTEGER

C PROGRAM TO FIND THE SUM OF INDIVIDUAL DIGITS OF A POSITIVE INTEGER


/* Write a C program to find the sum of individual digits of a positive integer.*/

#include<stdio.h>
#include<conio.h>

void main()
{
int num, k=1, sum=0;
clrscr();
printf(“Enter the number whose digits are to be added:”);
scanf(“%d”,&num);
while(num!=0)
{
k=num%10;
sum=sum+k;
k=num/10;
num=k;
}
printf(“Sum of the digits:%d”,sum);
getch();
}

Similar Posts:

 
 
Posted by 0 Responses

Categories:PREPARATION MATERIALS;Tags: , , , , ,

Free Email Newsletter

Stay Updates with this Blog. Get Free email newsletter updates..

And then confirm your email subcription

   

No Comment to “C PROGRAM TO FIND THE SUM OF INDIVIDUAL DIGITS OF A POSITIVE INTEGER”

  1. No Comment yet. Be the first to comment...
Leave your comment here:

 
Sponsored links
Free Email Updates
Get All Latest Updates in Ur e-mail Inbox..

And then confirm your email subcription

Sponsored Links