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


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

Introduction

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


  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4.  
  5. void functionupper(char []);
  6.  
  7. int main()
  8. {
  9. char string[100];
  10.  
  11. cout<<"Enter a string to convert it into upper case"<<endl;
  12. cin>>string;
  13.  
  14. functionupper(string); // calling functionupper
  15. cout<<"Entered string in upper case is: "<< string;
  16.  
  17. return 0;
  18. }
  19.  
  20. void functionupper(char s[]) {
  21. int c = 0;
  22.  
  23. while (s[c] != '\0') {
  24. if (s[c] >= 'a' && s[c] <= 'z') {
  25. s[c] = s[c] - 32;
  26. }
  27. c++;
  28. }
  29. }
  30.  

Result

C++ language techstudy.org

     





Related Topics




Popular Posts