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 is the purpose of void pointer?

1000


What is the difference between %d and %i?

1062


Function calling procedures? and their differences? Why should one go for Call by Reference?

1059


Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?

1030


What is memory leak in c?

1076


How to create struct variables?

1063


Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?

1459


write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

2486


How to delete a node from linked list w/o using collectons?

2741


Explain what is the advantage of a random access file?

1081


What is indirection?

1043


Explain why C language is procedural?

1171


How can I manipulate individual bits?

995


What the different types of arrays in c?

1033


When should I declare a function?

1076