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

How do we open a binary file in Read/Write mode in C?

1242


What are called c variables?

1068


What is an array? What the different types of arrays in c?

1189


Explain what will be the outcome of the following conditional statement if the value of variable s is 10?

1252


Can a pointer be volatile in c?

993


What is the deal on sprintf_s return value?

1139


Are local variables initialized to zero by default in c?

1053


What is difference between main and void main?

1215


What is main () in c?

1078


Why is main function so important?

1108


hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...

1919


how to find anagram without using string functions using only loops in c programming

3195


What is string in c language?

1162


What are shell structures used for?

1055


What are the header files used in c language?

1055