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
Is return a keyword in c?
Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1
in linking some of os executables are linking name some of them
please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com
What is const keyword in c?
What does & mean in scanf?
What does the error message "DGROUP exceeds 64K" mean?
Is a house a shell structure?
What is infinite loop?
What are the various types of control structures in programming?
Why malloc is faster than calloc?
What do you mean by a local block?
What is character set?
What are the key features in c programming language?
What is #pragma statements?