write a program to gat the digt sum of a number (et. 15=
>1+5=6)

Answer Posted / sagarsp2010

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,sum=0,no;
clrscr();

printf("ENTER THE NO. OF TERMS:");
scanf("%d",&n);

for (i=1;i<=5;i++)
{

no=n%10;
sum=sum+no;
n=n/10;

}
printf("sum=%d",sum);

getch();
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of gets and puts?

694


What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?

695


write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list

2366


What is atoi and atof in c?

708


regarding pointers concept

1676






swap 2 numbers without using third variable?

751


What is void main () in c?

830


we need to calculating INCOME TAX for the person. The INCOME TAX is as follows:- First $10000/- of income : 4% tax Next $10000/- of income : 8% tax Next $10000/- of income : 11.5% tax above $10, 00,00/- : 15% tax What is the Solution of this Question ?

910


What are global variables and how do you declare them?

696


What is the correct declaration of main?

770


Explain how can I convert a number to a string?

724


What is use of #include in c?

696


Why c is called a mid level programming language?

695


write a program to find out prime number using sieve case?

1728


What is ## preprocessor operator in c?

706