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...

if a five digit number is input through the keyboard, write
a program to calculate the sum of its digits.
(hint:-use the modulus operator.'%')

Answer Posted / richa

main()
{
int num , sum=0 ;
printf(" enter 5 digit no. " );
scanf(" %d " , num);
while (num!=0)
{ sum+=num%10;
num=num/10;
}
printf("sum is = %d " , sum );
getch();
}

Is This Answer Correct ?    24 Yes 16 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is multidimensional arrays

1082


Explain the use of #pragma exit?

1142


What are pointers? What are different types of pointers?

1086


Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

1051


C language questions for civil engineering

1673


What are global variables?

1138


Why n++ execute faster than n+1 ?

2888


using for loop sum 2 number of any 4 digit number in c language

2283


Is javascript based on c?

1019


What do you mean by c what are the main characteristics of c language?

996


What is the purpose of 'register' keyword in c language?

992


Where is volatile variable stored?

1044


What is non linear data structure in c?

984


What is the purpose of realloc()?

1101


Create a simple code fragment that will swap the values of two variables num1 and num2.

1243