Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the following C++ program that prints the content of a string in the re

ID: 3817687 • Letter: C

Question

Complete the following C++ program that prints the content of a string in the reverse order #include #include using namespace std; int main() { char str[] = “CSE 100 Fall 2014”; /* To Do: Select a for loop that prints the content of the string in the reverse order Hint: you can use strlen( const char* ) function to get the length of the string Ex. char str[] = "Cat"; int length; length = strlen(str); length gets 3. */ return 0; } 1. int i, length; length = strlen(str); for(i=0;i=0;i--){ cout<=0;i++){ cout<0;i--){ cout<

Explanation / Answer

In the above program , there are many syntex error in declration , so the Program corrected and modified to print the reverse of the string given below:-

#include<iostream>
#include<string.h>
using namespace std;

int main()
{
std::string str="CSE 100 Fall 2014"; //Declaration of the String
cout<<"Print the Original String as: "<<str<<endl;
int length=str.length(); // Find the length of the string
length--;
cout<<"Print the reverse String as: "<<endl;
for(int j=length;j>=0;j--)
cout<<str[j];
return 0;
}