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

What are the characteristics of arrays in c?

1049


Why isnt there a numbered, multi-level break statement to break out

1044


Why is c so important?

1060


What does sizeof int return?

1079


What are the 4 types of unions?

1034


Write the test cases for checking a variable having value in range -10.0 to +10.0?

2316


Write programs for String Reversal & Palindrome check

1057


Explain how can you check to see whether a symbol is defined?

1176


What is the use of getchar() function?

1127


What is the scope of global variable in c?

990


What are global variables and how do you declare them?

1091


What are the advantages of the functions?

1158


What is the basic structure of c?

1078


Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given

3060


which type of aspect you want from the student.

2162