K and R C Programs Exercises provides the solution to all the exercises in the C Programming Language (2nd Edition)
Write a C Functions like isupper() can be implemented to save space or to save time. Explore both possibilities. Read more about C Programming Language .
Normal C function:
int isupper(char c)
{
if (c >= 'A' && c <= 'Z')
return 1;
else
return 0;
}
This simple code tests the character is upper or lower , If the character within the range of ASCII upper case letters it returns 1, otherwise 0.
To save space or to save time using the macros is the best possibility
C Code:
#define isupper(c) ((c) > = 'A' && (c) <= 'Z') ? 1:0
Macro version of isupper is more efficient because, there is no overhead of the function call and it uses more space because the macro is expanded in line every time it is invoked.
Read more c programs
C Basic
C Strings
K and R C Programs Exercise
You can easily select the code by double clicking on the code area above.
To get regular updates on new C programs, you can Follow @c_program
You can discuss these programs on our Facebook Page. Start a discussion right now,
our page!
Share this program with your Facebook friends now! by liking it
(you can send this program to your friend using this button)
Like to get updates right inside your feed reader? Grab our feed!
2 comments on “K & R C Programs Exercise 7-9.”
plz do this pro. using rank function r which shows that input string is valid or not…… and if invalid than give the msg like" invalid string
not wrong ans
this program giv wrong ans in that type of condition
so plz improve
Hello!
Please rephrase your statement. I did not understand it.
Still better, send a detailed email to [email protected]
Thanks.