Функция isupper () на языке C

Опубликовано: 12 Апреля, 2022

Функция isupper () в программировании на C проверяет, является ли данный символ верхним регистром или нет. Функция isupper () определена в заголовочном файле ctype.h.
Синтаксис:

 int isupper (интервал x);

Examples:

Input: A
Output: Entered character is uppercase character
Input: a
Output: Entered character is not uppercase character
Input: 1
Output: Entered character is not uppercase character
// C program to demonstrate
// isupper() function
#include <ctype.h>
#include <stdio.h>
int main()
{
    char ch = "A";
  
    // checking uppercase
    if (isupper(ch))
        printf(" Entered character is uppercase character");
    else
        printf(" Entered character is not uppercase character");
}

Выход:

 Введен символ в верхнем регистре

Application : isupper() function in C programming language is used to find out total number of uppercase present in a given senence.
Example:

Input: GEEKSFORGEEKS
Output: Number of upper case present in the sentence is : 13
Input: GeeksFORGeeks
Output: Number of upper case present in the sentence is : 5
Input: geeksforgeeks
Output: Number of upper case present in the sentence is : 0
// C program to demonstrate
// isupper() function
  
#include <ctype.h>
#include <stdio.h>
  
// called function
int ttl_upper(int i, int counter)
{
    char ch;
    char a[50] = "GeeksForGeeks";
    ch = a[0];
  
    // counting of upper case
    while (ch != "") {
        ch = a[i];
        if (isupper(ch))
            counter++;
  
        i++;
    }
  
    // returning total number of upper case present in sentence
    return (counter);
}
int main()
{
    int i = 0;
    int counter = 0;
  
    // calling function
    counter = ttl_upper(i, counter);
    printf(" Number of upper case present in the sentence is : %d", counter);
    return 0;
}

Выход:

 Количество прописных букв в предложении: 3
Хотите узнать о лучших видео и практических задачах, ознакомьтесь с Базовым курсом C для базового и продвинутого C.



C