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

What does typeof return in c?

733


When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd

737


What is static volatile in c?

661


What is sizeof int in c?

705


How are pointers declared in c?

687






Explain how can I make sure that my program is the only one accessing a file?

736


Is c dynamically typed?

773


What is #define in c?

712


The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none

873


Why is structure important for a child?

710


What is a header file?

726


What is the difference between near, far and huge pointers?

704


Write a program to swap two numbers without using third variable in c?

712


What are the 4 data types?

676


Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?

1101