wk5_quiz_6.docx - Week 5 Quiz 6 Question 1 2 2 pts Complete the following C program that prints the content of a string in the reverse

wk5_quiz_6.docx - Week 5 Quiz 6 Question 1 2 2 pts Complete...

This preview shows page 1 - 5 out of 5 pages.

Week 5 Quiz 6 Question 12 / 2 ptsComplete the following C++ program that prints the content of a string in the reverse order#include<iostream>#include<cstring>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 orderHint: you can use strlen( const char* ) function to get the length of the stringEx. char str[] = "Cat"; int length; length = strlen(str);
Image of page 1
} cout<<endl; int i, length; length = strlen(str); for(i=length-1;i>=0;i++){ cout<<str[i]; } cout<<endl; int i, length; length = strlen(str); for(i=length;i>0;i--){ cout<<str[i]; } cout<<endl;
Image of page 2
Image of page 3
Image of page 4
Image of page 5

You've reached the end of your free preview.

Want to read all 5 pages?

  • Fall '17
  • FENG
  • Following, ASCII, char str

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture