c语言中isupper用法,C语言 isupper()用法及代码示例

C编程中的isupper()函数检查给定字符是否为大写。 isupper()函数在ctype.h头文件中定义。

用法:

int isupper ( int x );

例子:

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

#include

int main()

{

char ch = 'A';

// checking uppercase

if (isupper(ch))

printf("\nEntered character is uppercase character");

else

printf("\nEntered character is not uppercase character");

}

输出:

Entered character is uppercase character

应用:C编程语言中的isupper()函数用于查找给定句子中存在的大写字母总数。

例:

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

#include

// called function

int ttl_upper(int i, int counter)

{

char ch;

char a[50] = "GeeksForGeeks";

ch = a[0];

// counting of upper case

while (ch != '\0') {

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("\nNumber of upper case present in the sentence is:%d", counter);

return 0;

}

输出:

Number of upper case present in the sentence is:3

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值