using namespace std; void main() { char *str; //variable declaration str=new cha
ID: 3614853 • Letter: U
Question
using namespace std;
void main()
{
char *str; //variable declaration
str=new char[10]; //dynamic variable declaration
int p,i;
cout <<"Enter the number of characters in the string: ";
cin >> p;
//inputstring
for (i = 0; i < p; i++)
cin >> *(str+i);
//logic to convert string to uppercase
for (i = 0; i < p; i++)
{
if (*(str+i) >= 97)
*(str+i) = static_cast<char>
static_cast<int>(*(str+i))-32);
}
//output char array
for (i = 0; i < p; i++)
cout << *(str+i);
cout << endl;
}
Explanation / Answer
#include <iostream>
using namespace std;
void main()
{
char *str; //variable declaration
str=new char[10]; //dynamic variable declaration
int p,i;
cout <<"Enter the number of characters in the string: ";
cin >> p;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.