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

how to find sum of digits in C?

Answer Posted / deepak upadhyay

#include<stdio.h>
void main()
{
int num,a,b,c,d,e,sum;
printf("enter the num");
scanf("%d",&num);
a=num%10;
b=((num%100)-a)/10;
c=((num%1000)-(num%100))/100;
d=((num%10000)-(num%1000))/1000;
e=((num%100000)-(num%10000))/10000;
sum=a+b+c+d+e;
printf("\n1's place= %d \n10's place= %d \n100's
place= %d \n1000's place= %d \n10000's place=
%d",a,b,c,d,e);
printf("\nsum=%d",sum);
}

Is This Answer Correct ?    1 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .

2435


What is variable declaration and definition in c?

894


What do header files do?

1071


An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above

1166


What is pass by value in c?

1065


What is a floating point in c?

1069


What is the -> in c?

1007


a program that can input number of records and can view it again the record

1904


Explain Function Pointer?

1158


What is main function in c?

1075


Explain heap and queue.

1074


What are multidimensional arrays?

1113


a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list

1058


What are static variables in c?

1077


Find MAXIMUM of three distinct integers using a single C statement

1058