Convert Given String into Uppercase Using Library Function
#include
#include
#include
int main()
{
char
*string = "Pritesh Taral";
printf("String before to strupr : %sn", string);
strupr(string);
printf("String after strupr : %sn", string);
return
(0);
}
Output
String before to
strupr : Pritesh Taral
String after strupr :
PRITESH TARA
Program to Convert String into Uppercase Using Library Function
#include
#include
#include
int main()
{
char
string[100];
printf("Enter String : ");
gets(string);
strupr(string);
printf("String after strupr : %s", string);
return
(0);
}
Output
Enter String : Pritesh
Taral
String after strupr :
PRITESH TARAL
Count total number of capital and small letters from
accepted line
#include
#include
int main()
{
int upper
= 0, lower = 0;
char
ch[80];
int i;
printf("\nEnter The String : ");
gets(ch);
i =
0;
while
(ch[i] != '')
{
if
(ch[i] >= 'A' && ch[i] <= 'Z')
upper++;
if
(ch[i] >= 'a' && ch[i] <= 'z')
lower++;
i++;
}
printf("\nUppercase Letters : %d", upper);
printf("\nLowercase Letters : %d", lower);
return
(0);
}
Output
Enter The String :
Pritesh A Taral
Uppercase Letters : 3
Lowercase Letters : 10
Check Whether Entered Character is Uppercase Letter or Not
Without using Library Function
#include
#include
int main()
{
char ch;
printf("\nEnter The Character : ");
scanf("%c", &ch);
if
(ch >= 'A' && ch <= 'Z')
printf("Character
is Upper Case Letters");
else
printf("Character
is Not Upper Case Letters");
return
(0);
}
Output
Enter The Character :
A
Character is Uppercase
Letters
Check Whether Entered Character is Lowercase Letter or Not without
using Library Function
#include
#include
int main()
{
char ch;
printf("\nEnter The Character : ");
scanf("%c", &ch);
if
(ch >= 'A' && ch <= 'Z')
{
printf("Character
is uppercase Letters");
}
else if (ch >= 'a' && ch <=
'z')
{
printf("Character
is Not Lowercase Letters");
}
else
{
printf("Non
alphabet character");
}
return(0);
}
Output
Enter The Character :
a
Character is Lowercase
Letters
No comments:
Post a Comment