input any 4 digit number and find the difference of all the
digits?

Answer Posted / nitin garg

int j,num,rem,diff=0;
printf("
Enter Digit
");
scanf("%d",&num);

while(num!=0)
{
rem=num%10;
j=rem+rem;
diff=diff-rem;
num=num/10;
}
diff=diff+j;
printf("
Difference of Digit is : %d",diff);

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you return multiple values from a function?

635


Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?

586


Explain how can I pad a string to a known length?

655


Why static variable is used in c?

559


What is difference between union and structure in c?

581






Is c pass by value or reference?

596


Is struct oop?

583


When can a far pointer be used?

589


what is the format specifier for printing a pointer value?

617


What is pivot in c?

569


What is data structure in c programming?

575


Is c programming hard?

577


What is break statement?

634


main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }

914


Explain what is the difference between far and near ?

653