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 / revanth kumar.p

include<stdio.h>
#include<conio.h>
int main()
{
int num,len = 1,a,b;
printf("Enter a number");
scanf("%d",&num);
while(num >= 10)
{
num = num/10;
len++;
}
printf("%d",len);
a=len;
a=len*(len+1)%2;
printf("\n%d",a);
b=len;
b=len*(len+1)/2;
printf("\n%d",b);
a=a+b;
printf("\n%d",a);


getch();

}

Is This Answer Correct ?    4 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what value is returned to operating system after program execution?

2130


Why clrscr is used in c?

1020


What are local variables c?

1029


Why is %d used in c?

1012


how to introdu5ce my self in serco

2011


How many types of operators are there in c?

1042


application areas a 'c' a) operating system b) graphics, interpreter, assembler c) program evalution, communication softwares d) all the above

1075


What is a program flowchart and explain how does it help in writing a program?

1321


Which of the following operators is incorrect and why? ( >=, <=, <>, ==)

1177


Write a program to swap two numbers without using third variable in c?

1141


What is a macro in c preprocessor?

1108


Is boolean a datatype in c?

1076


Why do we use header files in c?

1084


Why do we use static in c?

1141


Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.

1245