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

#include<stdio.h>
#include<conio.h>
int main()
{
int n,m,m1,s=0,d,sum;
printf("\nEnter the number ");
scanf("%d",&n);
m=n%10;
d=n/10;
while(d>=10)
{
m1=d%10;
d=d/10;
s =s+m1;
}
sum=s+m+d;
printf("\nSum is %d",sum);
getch();
}

Is This Answer Correct ?    13 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a wrapper function in c?

1086


What is class and object in c?

1069


What is keyword with example?

1030


What is volatile variable how do you declare it?

1053


What are dangling pointers in c?

1153


What is the process of writing the null pointer?

1002


#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }

1019


What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

1186


In c programming language, how many parameters can be passed to a function ?

1072


Explain what is page thrashing?

1064


How pointer is different from array?

1033


Is malloc memset faster than calloc?

1030


Why enum is used in c?

918


How can I run c program?

1141


What is #include stdio h?

1078