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
The images I have uploaded are the part 1 to 4 and questions below are continue on the questions uploaded 5. C++ Class Template with Method Stubs #pragma once #include <iostream> #include <string> #include <stdexcept> #include <vector>   template <typename T> class HashTable { private:     struct Entry {         std::string key;         T value;         bool isOccupied;         bool isDeleted;         Entry() : key(""), value(), isOccupied(false), isDeleted(false) {}     };       Entry* table;     size_t capacity;     size_t size;     double loadFactorThreshold;           size_t customHash(const std::string& key) const {         size_t hash = 5381;         for (char c : key) {             hash = ((hash  <<  5) + hash)  +  c;         }         return hash;     }       size_t probe(const std::string& key, bool forInsert = false) const;     void resize();   public:     // Constructor     HashTable(size_t initialCapacity = 101);         // Big…
this project is NOT for graded(marks) purposes, please help me with the introduction. give me answers for the project. i will include an image explaining everything about the project.
Java Graphics (Bonus In this lab, we'll be practicing what we learned about GUIs, and Mouse events. You will need to implement the following: A GUI with a drawing panel. We can click in this panel, and you will capture those clicks as a Point (see java.awt.Point) in a PointCollection class (you need to build this). The points need to be represented by circles. Below the drawing panel, you will need 5 buttons: O о о ○ An input button to register your mouse to the drawing panel. A show button to paint the points in your collection on the drawing panel. A button to shift all the points to the left by 50 pixels. The x position of the points is not allowed to go below zero. Another button to shift all the points to the right 50 pixels. " The x position of the points cannot go further than the You can implement this GUI in any way you choose. I suggest using the BorderLayout for a panel containing the buttons, and a GridLayout to hold the drawing panel and button panels. Regardless of how…
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