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 / jegadeesh

#include<stdio.h>
void main()
{
int i,j;
scanf("%d",&i);
if((i%9)==0)
printf("The sum of digit is 9");
else
{
j=i%9;
printf("%d",j);
}
}

//the above will print result as 6 if given as 12345 since
1+2+3+4+5=15 and proceeding 1+5 we get as 6.....
is this an apt answer...

Is This Answer Correct ?    11 Yes 36 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What's the difference between constant char *p and char * constant p?

1147


What is the use of typedef in c?

1029


how to make a scientific calculater ?

2067


How arrays can be passed to a user defined function

1019


When is the “void” keyword used in a function?

1496


What are the main characteristics of c language describe the structure of ac program?

1208


#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }

1152


Explain bit masking in c?

1134


What is table lookup in c?

1098


What is the difference between %d and %i?

1092


What is the explanation for cyclic nature of data types in c?

1207


What is the purpose of ftell?

1076


What is a pointer on a pointer in c programming language?

1139


What is multidimensional arrays

1120


What is the purpose of void in c?

1067