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

What are the advantages of the functions?

1094


Write a program for finding factorial of a number.

1030


Is fortran faster than c?

982


Discuss the function of conditional operator, size of operator and comma operator with examples.

1093


Explain what is the difference between null and nul?

1080


I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.

2317


What is wild pointer in c?

1011


How can a program be made to print the line number where an error occurs?

1035


What is the purpose of & in scanf?

1007


How is pointer initialized in c?

975


Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent

2073


What is string function in c?

945


A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none

1145


largest Of three Number using without if condition?

1524


What is a stream water?

1124