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 / aryan garg

#include<stdio.h>
int main()
{
int n,d1,d2,d3,d4,d5,s;
printf("enter a five digit no");
scanf("%d",&n);
d5=n%10;n=n/10;
d4=n%10;n=n/10;
d3=n%10;n=n/10;
d2=n%10;n=n/10;
d1=n%10;
s=d1+d2+d3+d4+d5;
printf("sum of the digits of number is : %d",s);
return 0;
}

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is %d used in c?

1061


What is sizeof return in c?

1090


What is FIFO?

1840


What is pointer to pointer in c with example?

1158


What is a buffer in c?

1056


Is javascript based on c?

1117


Explain the difference between malloc() and calloc() function?

1102


any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above

1200


What are control structures? What are the different types?

1145


Which programming language is best for getting job 2020?

1101


What are the functions to open and close the file in c language?

1085


A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles

1233


Are comments included during the compilation stage and placed in the EXE file as well?

1127


how should functions be apportioned among source files?

1167


in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.

8118