write a program to gat the digt sum of a number (et. 15=
>1+5=6)
Answer Posted / santhosh kumar
#include<stdio.h>
#include<string.h>
int main ()
{
char no[100];
char num[2];
int i;
int length = 0;
int sum = 0;
memset(num, 0, 2);
printf("Enter the number: ");
gets(no);
length = strlen(no);
for(i=0; i<length; i++)
{
num[0] = no[i];
sum += atoi(num);
}
printf("Sum = %d", sum);
return 0;
}
Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
Explain logical errors? Compare with syntax errors.
Why do we use main function?
can we have joblib in a proc ?
Describe the steps to insert data into a singly linked list.
Which header file should you include if you are to develop a function which can accept variable number of arguments?
how is the examination pattern?
Why do we use namespace feature?
Hai what is the different types of versions and their differences
List some applications of c programming language?
What is the use of getch ()?
What is 2c dna?
Compare array data type to pointer data type
Explain how do you list files in a directory?
ATM machine and railway reservation class/object diagram
why do some people write if(0 == x) instead of if(x == 0)?