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

//sum of digits in c//
#include<stdio.h>
#include<conio.h>
void main()
{
int n,r,sum=0;
clrscr();
printf("\n enter the number:");
scanf("%d",&n);
while(n!=0)
{
r=n%10;
sum=sum+r;
n=n/10;
}
printf("sum=%d");
getch();
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you please explain the difference between malloc() and calloc() function?

1116


Why should I prototype a function?

1180


If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above

1058


What is a c token and types of c tokens?

1056


What is the significance of c program algorithms?

1141


Explain what is the general form of a c program?

1085


What are dangling pointers? How are dangling pointers different from memory leaks?

1297


How arrays can be passed to a user defined function

1017


Explain the difference between null pointer and void pointer.

1077


In a header file whether functions are declared or defined?

1122


What is an array in c?

1046


What is cohesion in c?

974


What are the different file extensions involved when programming in C?

1248


write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.

2855


What is the purpose of & in scanf?

1066