Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how to find sum of digits in C?

Answer Posted / giri

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

void main()
{
int sum=0, num, mul=1;
printf("Enter the number");
scanf("%d", &num);

while(num)
{
sum = sum + ((num%10)*mul);
num = num/10;
mul = mul * 10;
}

printf("Sum is %d", sum);
}

Is This Answer Correct ?    6 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?

1204


What is variable declaration and definition in c?

859


Is file a keyword in c?

890


what is the structure pointer?

2083


What is methods in c?

1035


Explain what are the different file extensions involved when programming in c?

1054


disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit

2020


Is there any demerits of using pointer?

1018


What is the explanation for modular programming?

1150


Write a code of a general series where the next element is the sum of last k terms.

992


how do you execute a c program in unix.

1078


The difference between printf and fprintf is ?

1217


What is the purpose of 'register' keyword?

1051


What is a program flowchart and how does it help in writing a program?

1086


What is property type c?

1047