Answer Posted / keerthireddy
#include<stdio.h>
#include<conio.h>
main()
{
int n,i,sum=0,r;
printf("enter the value");
scanf("%d",&n);
while(n>0)
{
r=n%10;
sum=sum+r;
n=n/10;
}
printf("sum = %d",sum);
}
output:
3456
how it works as follows:
3456%10 means it gives reminder as 6
6 will be added to the sum
3456/10 means it gives quotient as 345
then again loop is executing until the n value is 0
finally the result as 6+5+4+3=18
| Is This Answer Correct ? | 9 Yes | 1 No |
Post New Answer View All Answers
What does the characters “r” and “w” mean when writing programs that will make use of files?
Why we use conio h in c?
What Is The Difference Between Null And Void Pointer?
int far *near * p; means
What are the characteristics of arrays in c?
Explain the use of 'auto' keyword
Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.
Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.
Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..
Why clrscr is used after variable declaration?
What are the advantages of Macro over function?
What is the acronym for ansi?
all c language question
How to throw some light on the b tree?
hi send me sample aptitude papers of cts?