ATTENTION!!!: This assignment is for a basic and introductory C++ course. As suc
ID: 3836522 • Letter: A
Question
ATTENTION!!!: This assignment is for a basic and introductory C++ course. As such, please do not use complex or obscure opperations and headers that would typically be used in advanced classes as we have not learned them yet. Use only very simple functions and headers. If you are unsure of whether a technique is too advanced, dont use it. If you can answer the question without using a function, please do so.
"C type" string is implied to mean an array of characters with an end of string mark following the last character.
Write a function named ToUpper which will have one parameter (a “C type” string). The function will convert the string into all upper case characters.
Explanation / Answer
#include <iostream>
#include <cstring>
using namespace std;
void ToUpper (char a[]){
int i=0;
while(a[i]!=''){
if(a[i] >='a' && a[i] <='z'){
a[i]=a[i]-32;
}
i++;
}
}
int main()
{
char a[] = "abcbdebdcbsbabc";
cout<<a<<endl;
ToUpper(a);
cout<<a<<endl;
return 0;
}
Output:
sh-4.2$ g++ -std=c++11 -o main *.cpp
sh-4.2$ main
abcbdebdcbsbabc
ABCBDEBDCBSBABC
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.