input any 4 digit number and find the difference of all the
digits?
Answer Posted / senthil
char num[10];
printf ("Enter the number: ");
gets(num);
printf("Entered number = %s\n", num);
if (strlen(num) != 4) // check for 4 digit including NULL
{
printf("Error: number not 4 digit");
}
else
{
printf("\ndifference = %d", (num[0]&0x0F) - (num[1]&0x0F) - (num[2]&0x0F) - (num[3]&0x0F));
}
Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.
Explain how do you generate random numbers in c?
What are static variables in c?
When should a far pointer be used?
What are compound statements?
How does pointer work in c?
How can I list all of the predefined identifiers?
hi any body pls give me company name interview conduct "c" language only
How to create struct variables?
what are the facialities provided by you after the selection of the student.
What does int main () mean?
Explain how are 16- and 32-bit numbers stored?
What does struct node * mean?
What is the scope of local variable in c?
What is the difference between void main and main in c?