C How to Program (8th Edition)
C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 8, Problem 8.5E

(Character Testing) Write a program that inputs a character from the keyboard and tests it with each of the functions in the character-handling library. The program should print the value returned by each function.

Expert Solution & Answer
Check Mark
Program Plan Intro

Program Plan: 

  • mainfunction used to test all the functions.
  • Declare character type of variable character.
  • printf function used to print the formatted output on console.
  • scanf function used to takea formatted inputfrom console.

Program Description: 

The following program will input character and test all the character-handling library functions.

Explanation of Solution

Program: 

//header file included
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//included main function
intmain()
{
	//declare character type variable
char character;
//display message to user
printf("Enter the character:\n");
//input character
scanf("%c", &character);
//testing each function of character-handling library
//isdigit function
printf("'%c'%sdigit\n",character, isdigit(character)?"is a ":"is not a ");
//isalpha function
printf("'%c'%salphabet\n",character, isalpha(character)?"is a ":"is not a ");
//isalnum function
printf("'%c'%salpha-numeric\n",character, isalnum(character)?"is a ":"is not a ");
//isxdigit function
printf("'%c'%shexadecimal digit\n",character, isxdigit(character)?"is a ":"is not a ");
//islower function
printf("'%c'%slowercase letter\n",character, islower(character)?"is a ":"is not a ");
//isupper function
printf("'%c'%suppercase letter\n",character, isupper(character)?"is a ":"is not a ");
//toupper function
printf("The uppercase letter of '%c' is '%c'\n",character, toupper(character));
//tolower function
printf("The lowercase letter of '%c' is '%c'\n",character, tolower(character));
//isspace function
printf("'%c'%sspace\n",character, isspace(character)?"is a ":"is not a ");
//iscntrl function
printf("'%c'%scontrol character\n",character, iscntrl(character)?"is a ":"is not a ");
//ispunct function
printf("'%c'%sprinting character of ispunct\n",character, ispunct(character)?"is a ":"is not a ");
//isprint function
printf("'%c'%sprinting character of isprint\n",character, isprint(character)?"is a ":"is not a ");
//isgraph function
printf("'%c'%sprinting character of isgraph\n",character, isgraph(character)?"is a ":"is not a ");
//exiting from program
return 0;
}

Explanation:

In the above program, one character is inputted through scanf function. The %c is the format specifier used to input character type value. All the character-handling library function is used to test and print the output. The ternary operator is used inside the printf function to determine if the entered character is a digit, alphanumeric character, hexadecimal digit, lowercase letter or uppercase letter or not.

Sample Output:

  C How to Program (8th Edition), Chapter 8, Problem 8.5E

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
I want to ask someone who has experiences in writing physics based simulation software. For context I am building a game engine, and want to implement physics simulation. There are a few approaches that I managed to find, but would like to know what are other approaches to doing physics simulation entry points from scenes, would you be able to visually draw me a few approaches (like 3 approaces)? When I say entry point to the actual physics simulation. An example of this is when the user presses the play button in the editor, it starts and initiates the physics system. Applying all of the global physics settings parameters that gets applied to that scene. Here is the use-case, I am looking for. If you have two scenes, and select scene 1. You press the play button. The physics simulation starts. When that physics simulation starts, you are also having to update the physics through some physics dedicated delta time because physics needs to happen faster update frequency. To elaborate,…
I want to ask someone who has experiences in writing physics based simulation software. For context I am building a game engine, and want to implement physics simulation. There are a few approaches that I managed to find, but would like to know what are other approaches to doing physics simulation entry points from scenes, would you be able to visually draw me a few approaches (like 3 approaces)?When I say entry point to the actual physics simulation. An example of this is when the user presses the play button in the editor, it starts and initiates the physics system. Applying all of the global physics settings parameters that gets applied to that scene.Here is the use-case, I am looking for. If you have two scenes, and select scene 1. You press the play button. The physics simulation starts. When that physics simulation starts, you are also having to update the physics through some physics dedicated delta time because physics needs to happen faster update frequency.To elaborate, what…
Male comedians were typically the main/dominant star of television sitcoms made during the FCC licensing freeze.   Question 19 options:   True   False In the episode of The Honeymooners that you watched this week, why did Alice decide to get a job outside of the home?   Question 1 options:   to earn enough money to buy a mink coat   to have something to do while the kids were at school   to pay the bills after her husband got laid off
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Literals in Java Programming; Author: Sudhakar Atchala;https://www.youtube.com/watch?v=PuEU4S4B7JQ;License: Standard YouTube License, CC-BY
Type of literals in Python | Python Tutorial -6; Author: Lovejot Bhardwaj;https://www.youtube.com/watch?v=bwer3E9hj8Q;License: Standard Youtube License