C program Convert string to uppercase

We can write a c program to convert string to uppercase using strupr function, arrays and  pointers. strupr function in c language is used to convert string to uppercase. strupr function is defined under library string.h, so string.h file must be included before the program. The function strupr takes string parameter and returns same string in uppercase.If the input string is in uppercase then the output will in uppercase as it is.
syntax strupr ( string str)

Note: strupr() does not work in all compilers as its is not part of ANSI.
Use Turbo c  compiler for below programs

c program to convert string to uppercase using strupr function
c program to convert string to uppercase using strupr function

Write a C program to convert string to uppercase using strupr function

Write a C program to convert string to uppercase using strupr function

#include<stdio.h>
#include<string.h>
main()
{
char str[30];
printf(“…….To convert to uppercase…….”);
printf(“Enter a string to convert:”);
gets(str);
printf(“uppercase of entered string is: %s\n”,Strupr(str));
getch();
}

OUTPUT 1:

……..To convert to uppercase………

Enter a string to convert:
Hello World
uppercase of entered string is: HELLO WORLD

 

write a c program to convert strings in array to uppercase using strupr function

#include<stdio.h>
#include<string.h>
void main()
{
int i;
char str[5][30];
//str[no of strings][max string length]
printf(“To convert a strings in array to uppercase using strupr \n “);
for(i=0;i<5;i++)
{
printf(“Enter the string \n”);
gets(str);
}
for(i=0;i<5;i++)
printf(“\n uppercase of  string %s is:\n %s\n”, str, strupr(str));
getch();
}

OUTPUT :
To convert a strings in array to uppercase using strupr

Enter the string
programmingsimplysolved

Enter the string
Hello

Enter the string
hai

Enter the string
C Programming

Enter the string
THANKS

uppercase of  string programmingsimplysolved is :
PROGRAMMINGSIMPLYSOLVED

uppercase of  string Hello is :
HELLO

uppercase of  string hai is :
HAI

uppercase of  string C Programming is :
C PROGRAMMING

uppercase of  string THANKS is :
THANKS

 

Other programs:

Static variable scope
Register variable scope
External variable scope
Automatic variable scope
amicable number
Prime number
Perfect number
Palindrome number
Strong number
Find Factorial 
Biggest Number
Average of n numbers
convert decimal number to octal
decimal number to hexadecimal
decimal number to binary
simple interest
compound interest
Add sparce matrices
Add matrices
 file copying
Palindrome string
Reverse string
String length
Replace characters in string
substring or not using arrays
First occurrence of character in string
Last occurrence of character in string
Convert to uppercase
Convert to lowercase
Concatenate strings 
Compare strings
Generate Employee payslips
Count students scoring marks>50%
convert weight into grams

 

Leave a Reply

Your email address will not be published. Required fields are marked *