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
Is Exception handling possible in c language?
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?
A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference
What is dynamic dispatch in c++?
What are lookup tables in c?
Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer
the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function
7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.
What are derived data types in c?
What are control structures? What are the different types?
What is scanf_s in c?
Explain the priority queues?
How do I send escape sequences to control a terminal or other device?
Why c is a procedural language?
Difference between exit() and _exit() function?