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

What is structure in c language?

1096


In c language can we compile a program without main() function?

1057


What is character set?

1118


Explain what are its uses in c programming?

1015


Explain the difference between malloc() and calloc() function?

988


What is the use of in c?

947


Write the Program to reverse a string using pointers.

968


Can one function call another?

1051


what is stack , heap ,code segment,and data segment

2634


What is ctrl c called?

1002


Why pointers are used in c?

946


Why is a semicolon (;) put at the end of every program statement?

1030


What is the use of the function in c?

971


Why does not c have an exponentiation operator?

998


Explain what is gets() function?

1013