Tech Study

C++ Program to Change String to Upper Case

Introduction

I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.

#include <iostream>
#include <string.h>
using namespace std;
 
    void functionupper(char []);
 
    int main()
    {
       char string[100];
 
       cout<<"Enter a string to convert it into upper case"<<endl;
       cin>>string;
 
       functionupper(string); // calling functionupper
       cout<<"Entered string in upper case is: "<< string;
 
       return 0;
    }
 
    void functionupper(char s[]) {
       int c = 0;
 
       while (s[c] != '\0') {
          if (s[c] >= 'a' && s[c] <= 'z') {
             s[c] = s[c] - 32;
          }
          c++;
       }
    }

Result

Write C++ program to change string to upper case without strupr
Write C++ program to change string to upper case without strupr

Here are some more  c++ programs for your practice:

Write C++ program to reverse a string enter by user

Write C++ program to count number of alphabets, digits and special characters in string

 

TaggedWrite C++ program to change string to upper case without strupr

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more