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 / aha na

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,sum=0;
clrscr();
printf("\n enter a number",i);
scanf("%d",&i);

while(i<=0)
{
j=i%10;
sum=sum+j;
i=i/10;
}
printf("\n the sum of the digits
are:%d\n");
getch();
}

Is This Answer Correct ?    14 Yes 30 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Differentiate abs() function from fabs() function.

1070


How do you list files in a directory?

1207


Explain 'far' and 'near' pointers in c.

1186


What is a ternary operator in c?

1176


What are global variables and how do you declare them?

1167


How is pointer initialized in c?

1090


What is an array? What the different types of arrays in c?

1252


What is string constants?

1202


how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software

3371


Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10

15888


What is register variable in c language?

1060


What is the difference between char array and char pointer?

1118


How will you find a duplicate number in a array without negating the nos ?

2183


What are the different data types in C?

1246


What is the difference between printf and scanf in c?

1427