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 / revanth kumar.p
include<stdio.h>
#include<conio.h>
int main()
{
int num,len = 1,a,b;
printf("Enter a number");
scanf("%d",&num);
while(num >= 10)
{
num = num/10;
len++;
}
printf("%d",len);
a=len;
a=len*(len+1)%2;
printf("\n%d",a);
b=len;
b=len*(len+1)/2;
printf("\n%d",b);
a=a+b;
printf("\n%d",a);
getch();
}
| Is This Answer Correct ? | 4 Yes | 9 No |
Post New Answer View All Answers
How can I use a preprocessorif expression to ?
What do you mean by invalid pointer arithmetic?
Explain the use of 'auto' keyword
What is the difference between strcpy() and memcpy() function in c programming?
Who invented b language?
What are the ways to a null pointer can use in c programming language?
What is scanf () in c?
Describe the difference between = and == symbols in c programming?
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
What is string function 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
What is the difference between arrays and pointers?
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.
any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above
Is it possible to have a function as a parameter in another function?