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 / k.kavitha

main()
{
int num=0,sum=0,k=0;
pirntf("enter the number\n");
scanf("%d",num);
while(num!=0);
{
k=num%10;
sum=sum+k;
num=num/10;
}
printf("%d",sum);
}

Is This Answer Correct ?    137 Yes 90 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is typedef struct in c?

571


Is c language still used?

526


What is the meaning of c in c language?

586


What does #pragma once mean?

673


What is array of structure in c?

582






Explain what does the function toupper() do?

621


Where can I get an ansi-compatible lint?

628


What are the string functions? List some string functions available in c.

592


please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code

1694


What is indirection?

637


Can we replace the struct function in tree syntax with a union?

763


Why is python slower than c?

591


List the different types of c tokens?

604


What is c preprocessor mean?

769


How can you draw circles in C?

607