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
What is variable declaration and definition in c?
How can I automatically locate a programs configuration files in the same directory as the executable?
Write a program with dynamically allocation of variable.
How do you view the path?
Do you know what are bitwise shift operators in c programming?
How are pointers declared in c?
Which is an example of a structural homology?
Why is c not oop?
In a switch statement, what will happen if a break statement is omitted?
What are structure types in C?
Explain how do you print an address?
a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode
When is the “void” keyword used in a function?
How can you return multiple values from a function?
What language is windows 1.0 written?