wap in c to accept a number display the total count of digit
Answer Posted / santhi perumal
#include<stdio.h>
#include<conio.h>
int main()
{
int number,m,sum =0,count =0;
printf("Enter the number \n");
scanf("%d",&number);
while(number != 0)
{
m = number % 10;
sum = sum + m;
count++;
number = number / 10;
}
printf("\nThe number of Digits in the Given Number is
%d\n",count);
printf("The Sum of Digits in the Given Number is %d\n",sum);
}
| Is This Answer Correct ? | 19 Yes | 5 No |
Post New Answer View All Answers
Why header files are used?
What is an lvalue in c?
Explain the meaning of keyword 'extern' in a function declaration.
What are run-time errors?
Can we compile a program without main() function?
Explain how can I remove the trailing spaces from a string?
Why is c so popular?
code for replace tabs with equivalent number of blanks
What is identifiers in c with examples?
How do you declare a variable that will hold string values?
How can I trap or ignore keyboard interrupts like control-c?
stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.
Explain the array representation of a binary tree in C.
How is pointer initialized in c?
What is auto keyword in c?