Q:

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

belongs to collection: C++ language string programs

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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:

Enter a string to convert it into upper case

techstudy

Entered string in upper case is: TECHSTUDY

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write C++ program to change string to lower case w... >>
<< Write C++ program to convert a string to upper cas...