isupper() function in C++28 Aug 2024 | 4 min read The foundation of the C++ programming language is based on the concepts of object-oriented programming (OOP). Because C++ offers a clear structure, the user can develop and understand the program's concepts with ease. Furthermore, as functions are compact pieces of code, the concept has been made clear in C++ so that it can be used anywhere in a running program. One of the crucial C++ functions is the isupper() function, which is also predefined, saving us from having to write a large number of lines to implement it. You can use the isupper() method to determine whether a string or character is in upper-case letters or not. The capital letters from A to Z have ASCII values ranging from 65 to 90 in C++. The behavior of the isupper() function is undefinable if the input string or character value cannot be represented as an unsigned char or if it is not at the EOF (End of File). Syntax:It has the following syntax: Let's now talk about the isupper() function's implementation and writing style. First, we will take an integer type, after which we will write the isupper() function's name. After that, we will pass an integer-type parameter inside the function braces. Parameters:There are the following parameters in isupper() function. These are as follows: arg: It is the input string value or character value that needs to be checked for upper-case letters before being cast to an int or reaching the end of the file. Return Value:If the input string or character value is in uppercase letters, we will receive 1 in return, and else we will receive 0. Example 1:In this section, we'll construct the most basic example of the C++ function isupper(). A C++ IDE is required before we can begin coding to create and run the program. We will start implementing the program after launching the C++ compiler. We always start by incorporating the core program modules after starting the compiler. These modules are bundled in the C++ language modules. We simply need to type one line of code to include these modules instead of dozens of lines of code to construct the module. The "#" indicator informs the translator to load the module first before using the phrase "include" to add the module to the program. Now, we will take the module "iostream" to accept user data and show it to the user. After the "isostrem" module, we'll include the second module "#include cctype" in the program because we need to use the character function in the existing program. After that, we used the "using namespace std" directive to avoid objects, methods, and parameters from repeatedly referencing the same scope throughout the entire program. Code: Output: B is an uppercase letter Explanation: In this example, we will begin the main function to implement the program's true logic or problem. After that, write the code by launching the main() function bracket. Now, we contain the character type variable declaration and the character value's initialisation. Single or double quotation marks are always used to store the character type variable. After that, we have begun the if-else statement to determine whether the character variable is in an upper-case letter or not. We did so by including the isupper() method in the if-else. We printed the output using the cout() method. The predefined method in the C++ language is called cout(). Returning 0 to the main function indicates that the program ran effectively and achieved its objective. Example 02:Let's begin composing the isupper() function's second example. We normally include the modules that are linked to the program initially to use the operations in the existing program. For instance, if we want to display the program, we must use the cout() declaration. Therefore, we will utilise the "iostream" package to input and output program data. After that, the character function in the program is used after adding one more module. We will make use of the "cctype" module for that. After that, the "namespace std" directive will be used to avoid using the same name throughout the entire program. Code: Output: Here in this 2 uppercase letters in JtP. Explanation: In this example, the actual program code will be started by launching the main() method. After that, we declare the character type variable "ch" with a size of 20 and a value of the string "JtP". We have added two more integer-type variables, "count" and "i", and we have set 0 in each of them. After that, the while loop was employed to continue until the character string "ch[i]" was not null. We determine whether or not ch[i] is an upper-case string. If the first character is an uppercase character, the string will increase by 1. The compiler ends the while loop when the character string "ch[i]" is null. Afterwards, the cout() method publishes the input character string's total amount of upper-case letters. After closing the bracket around the main() method, we will return 0 to it to signal the end of the program's execution. ConclusionIn this article, we learnt how to utilize the isupper() function of the C++ language, which is used to determine how many letters are in upper case letters and whether the input string is in upper case letters or not. After that, we also constructed some examples, explaining each line as we wanted to learn more about the isupper() method. Next Topicnpos in C++ |
Drawing lines plays a pivotal role in computer graphics, whether we are developing a game, designing a user interface, or creating intricate visualizations. The Digital Differential Analyzer (DDA) line drawing algorithm emerges as a alent choice to facilitate this fundamental operation. In this blog post, we...
4 min read
QString is a popular class in Qt, a cross-platform application framework for developing GUI applications in C++. A QString is a Unicode string used to store and manipulate text. However, there are times when you may need to convert a QString to a hexadecimal representation. This...
3 min read
In this article, you will learn about the . But before discussing its implementation, you must know about the stringStream in C++. What is the stringstream in C++? A strong feature in C++ called StringStream enables smooth conversion between various data types and string representations. StringStream makes handling...
4 min read
? Competitive programming favors C++ because of its ability to combine efficiency and versatility. Runtime is optimized by its low-level features, which provide fine-grained control over algorithms. Code development is streamlined by the Standard Template Library (STL), which offers ready-to-use data structures and algorithms. Object-oriented, procedural, and...
4 min read
In this tutorial, we will write a c++ program to find the GCD of two numbers. GCD (Greatest common divisor) is also known as HCF (Highest Common Factor). For example 36 = 2 * 2 * 3 * 3 60 = 2 * 2 * 3 * 5 The highest common...
3 min read
What exactly is an opaque pointer? Opaque, as the name implies, is something that we cannot see through. Wood, for example, is opaque. An opaque pointer is one that points to a data structure whose contents are not known at the time it is defined. The pointer after...
3 min read
If you're dealing with visuals, writing a game demands some solid programming skills as well as a strong grasp of a few APIs, such as OpenGL and DirectX. For C++ programmers, there are a few gaming engines available to make the process straightforward. Necessary Header files The...
4 min read
Modular exponentiation is a base fundamental algoritm in number theory and cryptography that works to efficiently find the remainder of an integer raised to a power then divided by another integer. This algorithm proves to be quite productive in cases where working with large numbers...
5 min read
In this article, we will study the string__. We'll also see a programmed example of how to determine whether one string is contained inside another using the string::npos method. What is string_npos? The npos is the constant static member value with the maximum value for an element of...
3 min read
In C++, the cin.ignore() function is essential for resolving input-related problems, especially when using the cin and getline functions together. By clearing the input buffer and removing unnecessary characters, developers may ensure input processes behave as expected and accurately. In this article, we will examine the...
3 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India