Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Is return a keyword in c?

1080


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

4269


in linking some of os executables are linking name some of them

2129


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

1773


What is const keyword in c?

1162


What does & mean in scanf?

1105


What does the error message "DGROUP exceeds 64K" mean?

1218


Is a house a shell structure?

1160


What is infinite loop?

1083


What are the various types of control structures in programming?

1059


Why malloc is faster than calloc?

1064


What do you mean by a local block?

1085


What is character set?

1168


What are the key features in c programming language?

1072


What is #pragma statements?

1097